From 09135c581aaae471f7d964bc2a3a141bef299097 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 17 Jul 2020 07:05:03 +0200 Subject: Constrain base monad to MonadCatch Let's try MonadThrow/MonadCatch. It looks nice at a first glance. The monad transformer stack contains only the ReaderT, less lifts are required. Exception subtyping is easier, the user can (and should) define custom error types and throw them. And it is still possible to use pure error handling, if someone doesn't like runtime exceptions or need to run a query in a pure environment. Fixes #42. --- src/Language/GraphQL/Type/Out.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/Language/GraphQL/Type') diff --git a/src/Language/GraphQL/Type/Out.hs b/src/Language/GraphQL/Type/Out.hs index d094b4d..89bbf1d 100644 --- a/src/Language/GraphQL/Type/Out.hs +++ b/src/Language/GraphQL/Type/Out.hs @@ -33,7 +33,6 @@ module Language.GraphQL.Type.Out ) where import Conduit -import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Reader (ReaderT, asks) import Data.HashMap.Strict (HashMap) import qualified Data.HashMap.Strict as HashMap @@ -180,11 +179,11 @@ data Context = Context -- | Monad transformer stack used by the resolvers for determining the resolved -- value of a field. -type Resolve m = ExceptT Text (ReaderT Context m) Value +type Resolve m = ReaderT Context m Value -- | Monad transformer stack used by the resolvers for determining the resolved -- event stream of a subscription field. -type Subscribe m = ExceptT Text (ReaderT Context m) (SourceEventStream m) +type Subscribe m = ReaderT Context m (SourceEventStream m) -- | A source stream represents the sequence of events, each of which will -- trigger a GraphQL execution corresponding to that event. @@ -206,7 +205,7 @@ data Resolver m -- be optional then). argument :: Monad m => Name -> Resolve m argument argumentName = do - argumentValue <- lift $ asks $ lookupArgument . arguments + argumentValue <- asks $ lookupArgument . arguments pure $ fromMaybe Null argumentValue where lookupArgument (Arguments argumentMap) = -- cgit v1.2.3