Overloaded record fields

Adam Gundry adam.gundry at strath.ac.uk
Mon Jul 1 14:53:26 CEST 2013

Hi all,

I have amended the plan [1] as a result of the ongoing discussion,
including leaving the syntax alone for the time being, so record
projections are written prefix.

Regarding Barney's suggestion of field declarations:

On 01/07/13 10:50, Barney Hilken wrote:
> All this extra syntax, whether it's ., #, or {} seems very heavy for a problem described as very rare.
> Why not simply use a declaration
> 	field name
> whose effect is to declare 
> 	name :: r {name ::t} => r -> t
> 	name = getFld
> unless name is already in scope as a field name, in which case the declaration does nothing?

This makes sense. I guess the question is whether a new declaration form
is justified. The implementation is slightly more subtle than you
suggest, because we don't know whether `name` will be brought into scope
as a field later, in which case the definition would clash with the
actual field. It should be equivalent to defining

data Unused { name :: () }
data Unused2 { name :: () }

(twice so that there is always ambiguity about a use of `name`).



More information about the Glasgow-haskell-users mailing list