[Haskell-cafe] Re: Problem on existential type.

John Lato jwlato at gmail.com
Sat Sep 5 07:24:16 EDT 2009

Also, the two definitions for liftGW are exactly equivalent.  You have:

liftGW (GridWidget label) f = f label
liftGW (GridWidget textView) f = f textView

The only difference between the two is name to which the data
parameter to GridWidget is bound, which doesn't change the meaning at
all.  You should properly have

liftGW (GridWidget widget) f = f widget

There's no way to determine if that widget is a label or textView,
which is the whole point of existential types.


> From: Miguel Mitrofanov <miguelimo38 at yandex.ru>
> Subject: Re: [Haskell-cafe] Problem on existential type.
> To: Magicloud Magiclouds <magicloud.magiclouds at gmail.com>
> Your data type GridWidget doesn't have a parameter, yet you use it
> like it has one.
>> data GridWidget = forall widget. (WidgetClass widget) => GridWidget
>> widget
>                 ^
>                 |
> NB:-------------+
>> liftGW :: (GridWidget widget) -> (widget -> t) -> t

More information about the Haskell-Cafe mailing list