From 61879fb12437302d6b14e0e0297e3a8742d91f8b Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 8 Jul 2019 10:15:47 +0200 Subject: Constrain the resolvers with MonadIO This replaces the most usages of MonadPlus, which is not appropriate for the resolvers, since a resolver is unambiguously chosen by the name (no need for 'mplus'), and the resolvers are often doing IO. --- src/Language/GraphQL.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/Language/GraphQL.hs') diff --git a/src/Language/GraphQL.hs b/src/Language/GraphQL.hs index 8ed29cf..74052d9 100644 --- a/src/Language/GraphQL.hs +++ b/src/Language/GraphQL.hs @@ -1,8 +1,7 @@ -- | This module provides the functions to parse and execute @GraphQL@ queries. module Language.GraphQL where -import Control.Monad (MonadPlus) - +import Control.Monad.IO.Class (MonadIO) import qualified Data.Text as T import qualified Data.Aeson as Aeson @@ -21,7 +20,7 @@ import Language.GraphQL.Error -- executed according to the given 'Schema'. -- -- Returns the response as an @Aeson.@'Aeson.Value'. -graphql :: MonadPlus m => Schema m -> T.Text -> m Aeson.Value +graphql :: MonadIO m => Schema m -> T.Text -> m Aeson.Value graphql = flip graphqlSubs $ const Nothing -- | Takes a 'Schema', a variable substitution function and text @@ -30,7 +29,7 @@ graphql = flip graphqlSubs $ const Nothing -- query and the query is then executed according to the given 'Schema'. -- -- Returns the response as an @Aeson.@'Aeson.Value'. -graphqlSubs :: MonadPlus m => Schema m -> Subs -> T.Text -> m Aeson.Value +graphqlSubs :: MonadIO m => Schema m -> Subs -> T.Text -> m Aeson.Value graphqlSubs schema f = either (parseError . errorBundlePretty) (execute schema f) . parse document "" -- cgit v1.2.3