[Haskell-cafe] Data structure containing elements which are instances of the same type class

Jay Sulzberger jays at panix.com
Mon Aug 13 21:30:27 CEST 2012



On Mon, 13 Aug 2012, Johan Holmquist <holmisen at gmail.com> wrote:

> That pattern looks so familiar. :) Existential types seem to fit in to the
> type system really well so I never got why it is not part of the standard.
> On Aug 12, 2012 10:36 AM, "Daniel Trstenjak" <daniel.trstenjak at gmail.com>
> wrote:

Does Haskell have a word for "existential type" declaration?  I
have the impression, and this must be wrong, that "forall" does
double duty, that is, it declares a "for all" in some sense like
the usual "for all" of the Lower Predicate Calculus, perhaps the
"for all" of system F, or something near it.

oo--JS.


>
>>
>> Hi Oleg,
>>
>> On Sat, Aug 11, 2012 at 08:14:47AM -0000, oleg at okmij.org wrote:
>>> I'd like to point out that the only operation we can do on the first
>>> argument of MkFoo is to show to it. This is all we can ever do:
>>> we have no idea of its type but we know we can show it and get a
>>> String. Why not to apply show to start with (it won't be evaluated
>>> until required anyway)?
>>
>> It's only a test case. The real thing is for a game and will be
>> something like:
>>
>> class EntityT e where
>>    update      :: e -> e
>>
>>    render      :: e -> IO ()
>>
>>    handleEvent :: e -> Event -> e
>>
>>    getBound    :: e -> Maybe Bound
>>
>>
>> data Entity = forall e. (EntityT e) => Entity e
>>
>> data Level = Level {
>>    entities = [Entity],
>>    ...
>>    }
>>
>>
>> Greetings,
>> Daniel
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>



More information about the Haskell-Cafe mailing list