[Haskell-cafe] Re: [Haskell] pros and cons of static typing and side effects ?

Benjamin Franksen benjamin.franksen at bessy.de
Tue Aug 16 17:10:39 EDT 2005


On Tuesday 16 August 2005 22:29, Keean Schupke wrote:
> Benjamin Franksen wrote:
> >On Tuesday 16 August 2005 21:56, Keean Schupke wrote:
> >>You can even use existential types to create lists of things with a
> >>common interface, where you do not know in advance what types you
> >> may need:
> >>
> >>    data XWrap = XWrap (forall a . Show a => a)
> >>    type ListXWrap = [XWrap]
> >
> >You probably meant to write
> >
> >    data XWrap = forall a . Show a => XWrap a
> >
> >or, in GADT style (which I find a bit more intuitive here):
> >
> >    data XWrap where
> >      XWrap :: Show a => a -> XWrap
>
> Yes I always get confused by the notation Haskell uses... 

Same here.

> I used 
> explicit universal quantification by mistake. I tried to think
> logically about the encapsulation
> existential types represent - and got the wrong form.
>
> I for one would like to see the use of 'exists' as a keyword for
> existential types, after
> all different symbols are used in modal logic (upside-down-A for
> forall, and backwards-E
> for exists).

I once read a paper about type classes and existentials (can't remember 
exact title or author, was it Läufer?) where the proposal was to make 
existential quantification implicit (just as the universal one is in 
Haskell98). That is, any type variable that appears on the rhs of a 
data type, but not on the lhs, is implicitly existentially quantified, 
as in

  data XWrap = Show a => XWrap a

I always thought this was a pretty nice idea.

Ben


More information about the Haskell-Cafe mailing list