#StackBounty: #haskell #haskell-snap-framework Snap framework: Could not deduce (CI.MonadCatchIO (Handler App (AuthManager App))) in ha…

Bounty: 50

I’m using an openapi-based library within a handler; unfortunately it throws a lot of network or http exceptions, so I’m attempting to use Control.Monad.CatchIO with it, but banging my head against the types.

This is where I’m at:

{-# LANGUAGE ScopedTypeVariables #-}

import qualified Control.Monad.CatchIO as CI (try,MonadCatchIO)

-- this is the function that throws the exceptions
runQuery :: (Produces req accept, MimeUnrender accept b1, Show b1, MimeType contentType) => ServicesRequest req contentType b1 accept -> Handler App (AuthManager App) (Either MimeError b1)
runQuery r = ...


runQuery' :: forall req accept contentType b1. (Produces req accept, MimeUnrender accept b1, Show b1, MimeType contentType)
                       => ServicesRequest req contentType b1 accept
                       -> Handler App (AuthManager App) (Either E.SomeException (Either MimeError b1))
runQuery' req = 
  CI.try $ runCroesusQuery req :: Handler App (AuthManager App) (Either E.SomeException (Either MimeError b1))

Compiling gives this error message:

    * Could not deduce (CI.MonadCatchIO
                          (Handler App (AuthManager App)))
        arising from a use of `CI.try'
      from the context: (Produces req accept, MimeUnrender accept b1,
                         Show b1, MimeType contentType)
        bound by the type signature for:
                   runQuery' :: forall req accept contentType b1.
                                       (Produces req accept, MimeUnrender accept b1, Show b1,
                                        MimeType contentType) =>
                                       ServicesRequest req contentType b1 accept
                                       -> Handler
                                            App
                                            (AuthManager App)
                                            (Either E.SomeException (Either MimeError b1))
        at src/Helper/API.hs:(96,1)-(99,102)
    * In the expression: CI.try $ runQuery req
      In an equation for runQuery':
          runQuery' req = CI.try $ runQuery req

Any thoughts on how to proceed?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.