[Haskell-cafe] Could not deduce Monad m => MonadReader r (ReaderT r m) ??
David Turner
dct25-561bs at mythic-beasts.com
Thu Nov 26 14:48:55 UTC 2015
Porting some code from GHC 7.8.4 to GHC 7.10.2 and have encountered this
rather odd failure:
Could not deduce (MonadReader
(PqColumn m -> m B.ByteString)
(ReaderT (PqColumn m -> m B.ByteString) m))
arising from a use of ‘ask’
from the context (Monad m)
bound by the type signature for
readFieldByteString :: Monad m =>
PqColumn m -> RowReader m
B.ByteString
at src/EventStore/LibPq.hs:164:24-72
In a stmt of a 'do' block: readField <- ask
In the expression:
do { readField <- ask;
lift $ readField col }
In an equation for ‘readFieldByteString’:
readFieldByteString col
= do { readField <- ask;
lift $ readField col }
I wondered if it was because the environment type (PqColumn m -> m
B.ByteString) itself was an instance of MonadReader and the typechecker was
getting confused, so I put the environment in a newtype and it was indeed
happy.
Unfortunately I can't share enough of this code to get the problematic
fragment to compile, and my initial attempts at a small reproduction have
been unsuccessful. It's something like the following, but this compiles
just fine.
class MyClass m where
type MyType m
defaultValue :: m (MyType m)
l :: Monad m => MyType m -> ReaderT (MyType m -> m Int) m Int
l n = do
f <- ask
lift $ f n
Before I put more effort into reproducing this, does anyone recognise this
failure or know what might be going on here?
Cheers,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151126/782b470b/attachment.html>
More information about the Haskell-Cafe
mailing list