@@ -43,6 +43,7 @@ import qualified Data.ByteString.Lazy as B
43
43
import qualified Data.Aeson as A
44
44
import qualified Data.Vector as V
45
45
import qualified Data.HashMap.Strict as H
46
+ import Control.DeepSeq (NFData )
46
47
import Control.Monad (liftM )
47
48
import Control.Monad.Identity (runIdentity )
48
49
import Control.Monad.Error (runErrorT , throwError )
@@ -100,13 +101,13 @@ call = callWithBatchStrategy sequence
100
101
101
102
-- | Handles one JSON-RPC request.
102
103
callWithBatchStrategy :: Monad m =>
103
- (forall a . [m a ] -> m [a ]) -- ^ Function specifying the
104
- -- evaluation strategy.
105
- -> Methods m -- ^ Choice of methods to call.
106
- -> B. ByteString -- ^ JSON-RPC request.
107
- -> m (Maybe B. ByteString ) -- ^ The response wrapped in 'Just', or
108
- -- 'Nothing' in the case of a notification,
109
- -- all wrapped in the given monad.
104
+ (forall a . NFData a => [m a ] -> m [a ]) -- ^ Function specifying the
105
+ -- evaluation strategy.
106
+ -> Methods m -- ^ Choice of methods to call.
107
+ -> B. ByteString -- ^ JSON-RPC request.
108
+ -> m (Maybe B. ByteString ) -- ^ The response wrapped in 'Just', or
109
+ -- 'Nothing' in the case of a notification,
110
+ -- all wrapped in the given monad.
110
111
callWithBatchStrategy strategy fs input = either returnErr callMethod request
111
112
where request :: Either RpcError (Either A. Value [A. Value ])
112
113
request = runIdentity $ runErrorT $ parseVal =<< parseJson input
@@ -147,7 +148,7 @@ lookupMethod name = maybe notFound return . H.lookup name
147
148
throwInvalidRpc :: Monad m => Text -> RpcResult m a
148
149
throwInvalidRpc = throwError . rpcErrorWithData (- 32600 ) " Invalid JSON-RPC 2.0 request"
149
150
150
- batchCall :: Monad m => (forall a . [m a ] -> m [a ])
151
+ batchCall :: Monad m => (forall a . NFData a => [m a ] -> m [a ])
151
152
-> Methods m
152
153
-> [A. Value ]
153
154
-> m (Maybe [Response ])
0 commit comments