OK, thanks for this advice.

The type definition compiles, but when I try to actually access
myField, the compiler says:

Cannot use record selector `myField' as a function due to escaped type
variables
    Probable fix: use pattern-matching syntax instead

So I took the hint and wrote a new pattern matching accessor function:

getMyField (MyStruct value) = value

and I get:

Inferred type is less polymorphic than expected
      Quantified type variable `a' escapes
    When checking an existential match that binds
        value :: a

Any further suggestions?

On Sep 26, 1:09 pm, Daniel Fischer <[email protected]> wrote:
> On Sunday 26 September 2010 12:53:46, Michael Snoyman wrote:
>
> > data MyStruct = forall a. MyTypeClass a => MyStruct {myField :: a}
>
> Note that that requires
> {-# LANGUAGE ExistentialQuantification #-}
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to