> Many people have said this, but I still haven't found an instance where
> existential types are *needed*. For example, if you declare a data type:
How about this? Is the following example possibly accepted in any extended
Haskell system?
class Sequence seq a where
empty :: seq a
cons :: a -> seq a -> seq a
...
data Stack a = forall seq.(Sequence seq) => MkStack (seq a)
...
push a (MkStack seq) = MkStack (cons a seq)
...
I'd like to use Stack a, not one of (seq a) - possible representations for
Stack a.
Without existential type, could the level of abstraction like (Stack a) be
reached at?
[Please, look at STL's adapter classes - stack, queue, etc.]
P.S : Sorry for my bad english.