The code below compiles fine for me. Is it possible that the frameworks have moved on inthe meantime and things now just work?
However note the following changes I had to make as the world has changed a bit or I didn't have all your code. I used conduit-1.0.9.3 and persistent-1.3.0 with GHC 7.6.3.
Omitted
parseBytes
andserialise
as I don't have your definitions and definedDataType = ByteString
instead.Introduced a
Proxy
parameter and an explicit type signature for theundefined
value to avoid problems with type family injectivity. These likely don't arise in your real code because it will have a concrete or externally determined type forval
.Used
await
rather thanawaitE
and just used()
as the type to substitute for theLeft
case, asawaitE
has been retired.Passed a dummy
Connection
creation function towithSqlConn
- perhaps I should have used some Sqlite specific function?
Here's the code:
{-# LANGUAGE FlexibleContexts, NoMonomorphismRestriction,
TypeFamilies, ScopedTypeVariables #-}
module So133331988 where
import Control.Monad.Trans
import Database.Persist.Sql
import Data.ByteString
import Data.Conduit
import Data.Conduit.Binary
import Data.Proxy
test proxy =
withSqlConn (return (undefined "foo.db")) $ runSqlConn $ runResourceT $
sourceFile "in" $= dbAction proxy $$ sinkFile "out"
dbAction = filterP
type DataType = ByteString
filterP
:: forall m val
. ( MonadIO m, MonadBaseControl IO (SqlPersist m)
, PersistStore m, PersistEntity val
, PersistEntityBackend val ~ PersistMonadBackend m)
=> Proxy val
-> Conduit DataType m DataType
filterP Proxy = loop
where loop = await >>= maybe (return ()) go
go s = do lift $ insert (undefined :: val)
loop