Records in Haskell

Ian Lynagh igloo at
Mon Nov 7 23:33:51 CET 2011

On Mon, Nov 07, 2011 at 08:31:04PM +0200, Wolfgang Jeltsch wrote:
> The problem with this approach is that different labels do not have
> different representations at the value level. In my record system, I use
> label definitions like the following ones:
>     data MyName1 = MyName1
>     data MyName2 = MyName2

Instead of
    class Has (r :: *) (f :: String)       (t :: *) where
(as on the wiki), would it be possible to have something like
    class Has (r :: *) (ft :: *) (f :: ft) (t :: *) where
(where ft stands for field type)?

This could also solve the representation-hiding problem:

foo.field would use the string "field" as the field name, as in the
proposal on the wiki page.

But foo.Field (capital first letter) would use the constructor Field
that is in scope. If you don't want to export the field getter then
capitalise the first letter and don't export the constructor.


More information about the Glasgow-haskell-users mailing list