[Haskell-cafe] Hidden types and scope

Brandon Allbery allbery.b at gmail.com
Wed Jul 10 16:04:22 UTC 2019


You may need to study skolems / rank-N types. The exact scope of the "IO"
is inside the Wrapper, and nowhere else; so using it in let at all allows
it to be visible outside its scope. With the case expression, it can be
visible anywhere in the case alternative that pattern matches the Wrapper
without it necessarily escaping the scope (you could explicitly leak it,
but it will raise the same error about it escaping in that case).

GADTs are a way to get this same case matchung behavior, but it still
doesn't help you with this; you are asking that the compiler ignore the
rank of the type variable and make it visible outside its scope so that you
can use let instead of case, and ghc will not let you do this.

On Wed, Jul 10, 2019 at 11:57 AM Lana Black <lanablack at amok.cc> wrote:

> A followup question. What is the reason case and let expressions are
> treated differently in this case? I can see the error message saying
> about the type variable escaping its scope, but I don't understand how
> exactly this can happen with let.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.



-- 
brandon s allbery kf8nh
allbery.b at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190710/582ebe26/attachment.html>


More information about the Haskell-Cafe mailing list