[Haskell-cafe] existential types

Daniil Elovkov daniil.elovkov at googlemail.com
Wed Feb 13 08:19:09 EST 2008


Simeon Mattes wrote:
> 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,
> output
> :: 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 

I would say I don't see why this particular datatype is useful. I mean 
with no regard to existentials. Having output as a field in the data 
constructor seems strange to me.



More information about the Haskell-Cafe mailing list