On 02/07/13 10:57, Simon Peyton-Jones wrote:
Here is Plan A: use fundep (or type function)

    class Has r f t | r f -> t where
        getFld :: r -> t

    instance Has (R a) “foo” (a -> a) where ..
    instance Has S “bar” (forall b. b -> b) where ...

Lacking (as we still do) impredicative polymorphism, the S instance declaration
is rejected.

How common are such polymorphic fields in practice? You sometimes see them in newtype wrappers and the like. But I think those are not cases where you want overlapping names anyway.

So: why not use a Plan A style class, except for polymorphic fields? Perhaps you could still have a (less polymorphic) class for bar above,

    class HasBar r where
        getBar :: r -> b -> b


Twan

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to