Why does installing this elevator in a function work, but doesn’t directly call?

I see some strange behavior involving instances of the monad. I am writing a binding application and in one of my handlers, it will not compile unless I make a function.

Calling withManagerdirectly in my handler as follows:

authenticateLanding :: Handler App App ()
authenticateLanding = do
    req <- getRequest
    oir <- liftIO $ withManager $ OpenId.authenticateClaimed (convertParams req)
    writeBS (fromString $ show oir)

causes this compile-time error

openIDTrial.hs:120:25:
    No instance for (Control.Monad.Trans.Control.MonadBaseControl
                       IO m1)
      arising from a use of `withManager'
    Possible fix:
      add an instance declaration for
      (Control.Monad.Trans.Control.MonadBaseControl IO m1)
    In the expression: withManager
    In the second argument of `($)', namely
      `withManager $ OpenId.authenticateClaimed (convertParams req)'
    In a stmt of a 'do' block:
      oir <- liftIO
             $ withManager $ OpenId.authenticateClaimed (convertParams req)

However, if I put it in a function, then I do not get this error

claim params = liftIO $ withManager $ OpenId.authenticateClaimed (params)

authenticateLanding :: Handler App App ()
authenticateLanding = do
    req <- getRequest
    oir <- claim (convertParams req)
    writeBS (fromString $ show oir)

Something about this does not make sense, since the claim function is not trying to add additional information to the compiler.

+5
source share

All Articles