Open MichaelXavier opened 9 years ago
Note the type of liftWith
:
liftWith :: Monad m => (Run t -> m a) -> t m a
type Run t = forall n b. Monad n => t n b -> n (StT t b)
So the Run
function needs to be able to run t n
for all n
. However in your:
liftWith f = FooT $ \r -> f $ \t -> runFooT t r
your Run
function: \t -> runFooT t r
has the type: FooT m a -> m (StT (FooT m) a)
where m
is bound by the type of your liftWith :: forall m a. (Run FooT -> FooT m a) -> FooT m a
This is a known problem of monad-control
and also described in #4.
A solution in monad-control
would be to parameterise Run
with m
as in:
type Run t m = forall a. t m a -> m (StT t a)
However this could lead to some "bad" instances. @andersk do you remember why this was important?
Hi, I've been struggling with this one for the better part of a day. I think this may be an issue that can be easily solved with clever type annotations but for the life of me I can't figure it out. Here's the minimal case reduced from my problem:
and the error:
It seems like m undergoes a type change somewhere or the type is ambiguous. I've tried many permutations of scoped type variables and annotation and I can't get
m
andn
to unify. Any ideas?