[Haskell-cafe] Re: Polymorphic record field?

Kevin Jardine kevinjardine at gmail.com
Sun Sep 26 08:00:38 EDT 2010

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
    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 <daniel.is.fisc... at web.de> 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
> Haskell-C... at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list