<div dir="ltr">Hello -<div><br></div><div>I have a typeclass like this ..<div><br></div><div><font face="monospace">class (Monad m) => DB m where<br>    query :: Text -> m (Maybe Account) </font></div><div><font face="monospace">    ...</font></div><div><br></div><div>and an instance that uses persistent and sqlite ..</div><div><br></div><div><font face="monospace">instance (MonadIO m) => DB (SqlPersistT m) where<br>  query ano = get (AccountKey ano)</font></div><div><font face="monospace">  ..</font><br><div><br></div><div>Now I want to move this to using an effect system - Polysemy ..</div><div><br></div><div><font face="monospace">data DB m a where<br>    Query :: Text -> DB m (Maybe Account)<br>    ...</font></div><div><br><font face="monospace">makeSem ''DB<br></font></div><div><br></div><div>which generates the functions .. I need some help figuring out the type of the function that interpretes the above .. An initial intuition is this ..</div><div><br></div><div><font face="monospace">runDB :: Member SqlPersistT r => Sem (DB ': r) a -> Sem r a<br>runDB = interpret $ \case<br>  Query ano -> get (AccountKey ano)</font><br></div><div><br></div><div>which doesn't compile .. errors out with ..</div><div><br></div><div>Couldn't match type ‘Control.Monad.Trans.Reader.ReaderT backend0 m0 (Maybe Account)’<br>                 with ‘Sem r (Maybe Account)’<br>  Expected type: Sem r x<br>    Actual type: Control.Monad.Trans.Reader.ReaderT<br>                   backend0 m0 (Maybe Account)<br>• In the expression: get (AccountKey accountNo)<br></div><div><br></div><div>I think I am missing something here. The type of <font face="monospace">interpret</font> is shown as </div><div><font face="monospace">interpret :: (forall x (m :: * -> *). DB m x -> Sem r x) -> Sem (DB : r) a -> Sem r a<br></font></div><div><br></div><div>But how do I translate the <font face="monospace">SqlPersistT</font> part ? Any help will be appreciated.</div><div><br></div><div>regards.</div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Debasish Ghosh<br><a href="http://manning.com/ghosh2" target="_blank">http://manning.com/ghosh2</a></div><div><a href="http://manning.com/ghosh" target="_blank">http://manning.com/ghosh</a><br></div><div><br>Twttr: @debasishg<br>Blog: <a href="http://debasishg.blogspot.com" target="_blank">http://debasishg.blogspot.com</a><br>Code: <a href="http://github.com/debasishg" target="_blank">http://github.com/debasishg</a></div></div></div></div></div></div>