The only knowledge the type system has about a GridWidget is that it
contains /some thing/ which is a member of the WidgetClass typeclass.
So the only thing you can do with the thing inside the GridWidget is
to apply functions of the WidgetClass. It might be easier to see with
the Show class instead of your WidgetClass.

data GridWidget = forall w. (Show w) => GridWidget w

foo :: GridWidget -> String
foo (GridWidget w) = show w

foo $ GridWidget "hi there"
> "hi there"
foo $ GridWidget (3, 5)
> "(3,5)"
map foo [GridWidget True, GridWidget 3.14159]
>["True", "3.14159"]

But 'show' is the only function you can apply to values inside of a
GridWidget because it is the only function of the Show class. The same
holds for you WidgetClass.


On Fri, Sep 4, 2009 at 8:13 AM, Miguel Mitrofanov<miguelim...@yandex.ru> wrote:
> 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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to