[Haskell-cafe] How to bring existentially quantified type variables into scope

Wolfgang Jeltsch wolfgang-it at jeltsch.info
Fri Aug 11 00:08:03 UTC 2017


Am Donnerstag, den 10.08.2017, 19:39 -0400 schrieb Ben Gamari:
> On August 10, 2017 7:16:04 PM EDT, Wolfgang Jeltsch wrote:
> > Consider, for example, the following definition:
> > 
> > > data IsListType a where
> > > 
> > >     IsListType :: IsListType [b]
> >
> > For each type T, we can match a value of type IsListType T against
> > the pattern IsListType. If this succeeds, we know that T is a list
> > type, but we do not have access to the respective element type.
> > 
> > Is there a way to determine existentially quantified type variables
> > like the b in the above example?
>
> Note that the feature described in #11350 will provide a quite direct
> way to accomplish this by allowing type applications in pattern
> matches.

Yes, this feature seems to provide what I need. In my particular use
case, it allows for pretty clear code.

Is there also a solution that does not involve using this
(unimplemented) feature?

All the best,
Wolfgang


More information about the Haskell-Cafe mailing list