Update to Stack 15.x

This commit is contained in:
Eugen Wissner 2020-02-20 05:16:14 +01:00
parent c0e5e30e76
commit 613e929d91
4 changed files with 13 additions and 12 deletions

View File

@ -15,7 +15,6 @@ module Language.GraphQL.AST.Encoder
import Data.Char (ord) import Data.Char (ord)
import Data.Foldable (fold) import Data.Foldable (fold)
import Data.Monoid ((<>))
import qualified Data.List.NonEmpty as NonEmpty import qualified Data.List.NonEmpty as NonEmpty
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as Text import qualified Data.Text as Text

View File

@ -20,18 +20,20 @@ import Control.Monad.Trans.State ( StateT
, modify , modify
, runStateT , runStateT
) )
import Text.Megaparsec ( ParseErrorBundle(..) import Text.Megaparsec
, SourcePos(..) ( ParseErrorBundle(..)
, errorOffset , PosState(..)
, parseErrorTextPretty , SourcePos(..)
, reachOffset , errorOffset
, unPos , parseErrorTextPretty
) , reachOffset
, unPos
)
-- | Wraps a parse error into a list of errors. -- | Wraps a parse error into a list of errors.
parseError :: Applicative f => ParseErrorBundle Text Void -> f Aeson.Value parseError :: Applicative f => ParseErrorBundle Text Void -> f Aeson.Value
parseError ParseErrorBundle{..} = parseError ParseErrorBundle{..} =
pure $ Aeson.object [("errors", Aeson.toJSON $ fst $ foldl go ([], bundlePosState) bundleErrors)] pure $ Aeson.object [("errors", Aeson.toJSON $ fst $ foldl go ([], bundlePosState) bundleErrors)]
where where
errorObject s SourcePos{..} = Aeson.object errorObject s SourcePos{..} = Aeson.object
[ ("message", Aeson.toJSON $ init $ parseErrorTextPretty s) [ ("message", Aeson.toJSON $ init $ parseErrorTextPretty s)
@ -39,7 +41,8 @@ parseError ParseErrorBundle{..} =
, ("column", Aeson.toJSON $ unPos sourceColumn) , ("column", Aeson.toJSON $ unPos sourceColumn)
] ]
go (result, state) x = go (result, state) x =
let (sourcePosition, _, newState) = reachOffset (errorOffset x) state let (_, newState) = reachOffset (errorOffset x) state
sourcePosition = pstateSourcePos newState
in (errorObject x sourcePosition : result, newState) in (errorObject x sourcePosition : result, newState)
-- | A wrapper to pass error messages around. -- | A wrapper to pass error messages around.

View File

@ -1,4 +1,4 @@
resolver: lts-14.25 resolver: lts-15.0
packages: packages:
- . - .

View File

@ -16,7 +16,6 @@ module Test.StarWars.Data
, typeName , typeName
) where ) where
import Data.Monoid (mempty)
import Data.Functor.Identity (Identity) import Data.Functor.Identity (Identity)
import Control.Applicative (Alternative(..), liftA2) import Control.Applicative (Alternative(..), liftA2)
import Control.Monad.Trans.Except (throwE) import Control.Monad.Trans.Except (throwE)