[Haskell-cafe] existential types

Simeon Mattes simeon.mattes at gmail.com
Wed Feb 13 06:57:58 EST 2008

I have found that ghc has adopted the existential data constructors. Because it
was first time I have heard this term I have found some articles about it. The
less complex for me was the following explanation

data Worker x y = Worker {buffer :: b, input :: x, output :: y}

This is wrong in Haskell98 because we can 't just hide buffer :: b. We should
write instead data Worker b x y = Worker {buffer :: b, input :: x, output :: y}

Let suppose that b has an indefinite type. Then with existential types we could
write data Worker x y = forall b. Buffer b => Worker {buffer :: b, input :: x,
:: y}

The example above is similar to the example that Paul Hudak, John Hughes, Simon
Peyton Jones and Philip Wadler mention in an article "a history of Haskell".

Though I can't figure out how exactly could utilize such a type. To be honest
haskell is my first functional language and I 'm not so familiar with. So, an
example would be very helpful 

More information about the Haskell-Cafe mailing list