[Haskell-cafe] Hidden types and scope

Benjamin Franksen ben.franksen at online.de
Thu Jul 11 15:11:09 UTC 2019

Am 10.07.19 um 18:03 schrieb Sandeep.C.R via Haskell-Cafe:
>>What is the reason case and let expressions are treated differently in
> this case
> Please check the section " Restrictions section" in
> https://downloads.haskell.org/~ghc/7.6.3/docs/html/users_guide/data-type-extensions.html
> It says,
>>In general, you can only pattern-match on an existentially-quantified
> constructor in a case expression or in the patterns of a function
> definition. The reason for this restriction is really an implementation
> one. Type-checking binding groups is already a nightmare without
> existentials complicating the picture. Also an existential pattern
> binding at the top level of a module doesn't make sense, because it's
> not clear how to prevent the existentially-quantified type "escaping".
> So for now, there's a simple-to-state restriction. We'll see how
> annoying it is.

FWIW, I personally do find the restriction pretty annoying (even though
by now I am quite used to it).

In some cases one can work around it by using pattern guards instead of
let/where, since these are also exempt.


More information about the Haskell-Cafe mailing list