Type error: Expected type: T. Actual type T ???

Brandon Allbery allbery.b at gmail.com
Sun Oct 30 01:33:50 CEST 2011

On Sat, Oct 29, 2011 at 16:18, Bas van Dijk <v.dijk.bas at gmail.com> wrote:

> type Run t = ∀ n β. Monad n ⇒ t n β → n (St t β)
> foo :: (Monad m, MonadTransControl t) => (Run t -> m α) -> t m α
> foo f = liftControl f
> Type checking 'foo' this gives the following error:
>    Couldn't match expected type `Run t' with actual type `Run t'

I *think* this might be odd reporting combined with an expected behavior:
 since the forall is embedded in the "type" declaration, the "t" inside the
parens is not the same as the one outside (because each one has its own
"forall" associated with it).  If the type is inferred, the inference gets
the association right, but the explicit "forall" from the definition of
(Run t) used inside the parens tells ghc that they should be different.

(I *think* this might mean manually expanding "Run t" and moving the
"forall" to the outer scope, but now we're into territory I don't
understand very well.)

brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20111029/1b26476c/attachment.htm>

More information about the Glasgow-haskell-users mailing list