[web-devel] A little trouble upgrading to conduit 0.4.x

Bardur Arantsson spam at scientician.net
Wed Apr 4 16:17:05 CEST 2012


Hi all,

I'm upgrading various bits and bobs to conduit 0.4.x, but I've hit a 
little snag with "sourceStateIO". The following function fails to compile:

 > sourceQuery :: Database -> String -> [SQLData] -> Source IO [SQLData]
 > sourceQuery database sql parameters =
 >   sourceStateIO
 >   (do
 >       stmt <- SQL.prepare database sql
 >       return (Unbound,stmt))
 >   (\(_,stmt) -> SQL.finalize stmt)
 >   (\(state,stmt) -> do
 >       -- Bind parameters if necessary.
 >       when (state == Unbound) $ do
 >         SQL.bind stmt parameters
 >       -- Fetch results.
 >       nextResult <- SQL.step stmt
 >       case nextResult of
 >         Done -> return StateClosed
 >         Row -> liftM (StateOpen (Bound,stmt)) $ SQL.columns stmt)

All the SQL.xyz bits run in the IO monad. This code runs fine in Conduit 
0.2.x, but on Conduit 0.4.x it fails to compile with the following error:

src/Data/CQRS/EventStore/Backend/Sqlite3Utils.hs:43:3:
     No instance for 
(resourcet-0.3.2:Control.Monad.Trans.Resource.MonadResource
                        IO)
       arising from a use of `sourceStateIO'
     Possible fix:
       add an instance declaration for
       (resourcet-0.3.2:Control.Monad.Trans.Resource.MonadResource IO)
     In the expression:
       sourceStateIO
         [rest elided; just the rest of the definition of sourceQuery]
     In an equation for `sourceQuery':
         sourceQuery database sql parameters
           = sourceStateIO
		[rest elided; just the rest of the definition of sourceQuery]

I can see that I'm missing an instance, but I can't seem to find a 
direct instance for MonadResource IO, nor can I tell which indirect 
instance could get me there. I there some specific import I need to get 
the necessary instances, or do I need to do something else?

Regards,




More information about the web-devel mailing list