Records in Haskell

Simon Peyton-Jones simonpj at
Mon Jan 16 11:32:54 CET 2012

Johan, if you are serious, do add a new wiki page to describe the design.

You say it's simple, but I don't think it really is.  The whole qualified name story is *already* pretty complicated: see

Particular issues I can think of immediately:

1. What about data families

	data instance T [a] = MkT { x :: Int }
   	data instance T Bool = T2 { x :: Bool }

What are the qualifies names for the two x's?

2.  Module exports.  What about

	module M( S(..), T(..) ) where
 	  data S = MkS { x :: Int }
	  data T = MkT { x :: Int }

When you import M, what comes into scope?  

3. If you import the record field without the type name (currently possible) does that make the record field impossible to disambiguate?  Or is it still ok to disambiguate it with the type name.

My concern would be that it's quite a lot of work to specify and implement; but still might not do the job in the eyes of our users.


| -----Original Message-----
| From: Johan Tibell [mailto:johan.tibell at]
| Sent: 14 January 2012 18:39
| To: Simon Peyton-Jones
| Cc: Greg Weber; ingo.wechsung; glasgow-haskell-users at
| Subject: Re: Records in Haskell
| On Fri, Jan 13, 2012 at 3:52 PM, Simon Peyton-Jones
| <simonpj at> wrote:
| > I know of no proposal that advocates only (A).  It seems that we are agreed
| > that we must make use of types to disambiguate common cases.
| I will try to make the case for (A), just so it has been put on the table.
| Proposal
| =========
| The proposal is to implement
| without
| any of the type resolution parts. I think this approach is dismissed a
| bit to easily on the wiki page above:
|     "We have name-spaces, but it is hard to see how this is better
| than the current practice of adding prefixes to record fields: data
| Record = Record { recordA :: String }"
| There are (at least) three benefits of using namespaces (e.g.
| 'Record.a') rather than ad-hoc prefixes (e.g. 'recordA'):
|  * You can use a type synonym to abbreviate the namespace part (as
| shown on the wiki page.)
|  * If there's no ambiguity you don't need to use a namespace (e.g. you
| can use 'a' instead of 'Record.a').
|  * The namespace name is predictable (e.g. <Typename>.<fieldname>)
| while ad-hoc prefixes tend to use different conventions e.g. the whole
| record name (e.g. 'recordA') or some abbreviation thereof (e.g.
| 'rcrdA'.)
| The main argument for this approach is its simplicity; it's simple to
| understand for users and (hopefully) simple to implement.
| Cheers,
| Johan

More information about the Glasgow-haskell-users mailing list