4

I tried to follow along this connecting-http-conduit-to-xml-conduit stackoverflow question, as it looks exactly like what I want to do.

I'm building off of the example from the http-conduit section of the yesod book.

The Code

getBody = do
   manager <- liftIO $ newManager def
   req <- liftIO $ parseUrl fredURL
   http req manager

The Error

No instance for (monad-control-0.3.1.3:Control.Monad.Trans.Control.MonadBaseControl
                   IO m0)
  arising from a use of `http'
Possible fix:
  add an instance declaration for
  (monad-control-0.3.1.3:Control.Monad.Trans.Control.MonadBaseControl
     IO m0)
In a stmt of a 'do' block: http req manager
In the expression:
  do { manager <- liftIO $ newManager def;
       req <- liftIO $ parseUrl fredURL;
       http req manager }
In an equation for `getBody':
    getBody
      = do { manager <- liftIO $ newManager def;
             req <- liftIO $ parseUrl fredURL;
             http req manager }

The Goal

I'm trying to return a Source that will be used by an xml-conduit Sink, the intent being that I want to use XML-Conduit to parse the XML and express it as a Haskell data type. Could I get some elucidation as to why I am getting my error?

Community
  • 1
  • 1
  • 1
    Can you put the code up somewhere? I'd guess that you're lacking a type signature. Turning on -XNoMonomorphismRestriction might help if you don't know what the type is supposed to be. – Nathan Howell Aug 09 '12 at 21:19
  • I added NoMonomorphismRestriction. It compiles now. Could you tell me why it's neccesary? –  Aug 10 '12 at 00:19
  • It's not necessary, adding a type signature will fix it too. Sometimes if I'm not writing type signatures first, I'll enable the `NoMonomorphismRestiction` and inspect the inferred type in GHCi... often times you can just copy & paste the type signature directly into your code and disable the NMR flag. There is a lot of information around on this subject, you can read about it here: http://www.haskell.org/haskellwiki/Monomorphism_restriction. Unfortunately the error message for these errors aren't terribly enlightening. – Nathan Howell Aug 10 '12 at 00:30
  • @NathanHowell you should post your comment as an answer, since it resolves the question. – sclv Feb 05 '13 at 00:50

0 Answers0