[Haskell-cafe] Problem on existential type.
magicloud.magiclouds at gmail.com
Mon Sep 7 04:45:36 EDT 2009
Thank you all guys. This explained so much.
On Sun, Sep 6, 2009 at 2:53 AM, Ryan Ingram<ryani.spam at gmail.com> wrote:
> On Thu, Sep 3, 2009 at 11:05 PM, Magicloud
> Magiclouds<magicloud.magiclouds at gmail.com> wrote:
>> data GridWidget = forall widget. (WidgetClass widget) => GridWidget widget
>> liftGW :: (GridWidget widget) -> (widget -> t) -> t
>> liftGW (GridWidget label) f = f label
>> liftGW (GridWidget textView) f = f textView
> The type signature on liftGW is wrong. Also, as mentioned elsewhere,
> the two matches overlap; the second case never gets called.
> The correct type signature for "liftGW" is:
> liftGW :: GridWidget -> (forall widget. WidgetClass widget => widget -> t) -> t
> Note that the "f" passed in has to accept *any* widget type, so it's
> possible that existential types aren't what you want.
> -- ryan
More information about the Haskell-Cafe