Why I Want Global Field Names (By Default)

AntC anthony_clayden at clear.net.nz
Mon Mar 5 12:06:41 CET 2012

Gershom Bazerman <gershomb <at> gmail.com> writes:


Gershom, an implementation question for your proposed approach to 

(It's always easy to wave away awkwardness if you don't show the full 
mechanism. Please write up your proposal on the wiki to the same level of 
detail as SORF -- at least!.)

>     However, we can do one better, and recover DORF and SORF behavior at
>     once!
>         class Label a
>         class Label f => Has (r :: *) (f :: *) (t :: *) where
>            get :: r -> t
>        instance Label (a :: String)

SORF is not proposing any change to data decls syntax, or the namespacing 
around field selector functions. How do you get from the data decl to the Has 
instance? (So that the program can get/set within its private module.)

Specifically, with:
>        data MyPrivateLabel
>        instance Label MyPrivateLabel

How to get a data decl to generate a Has instance for MyPrivateLabel, and 
avoid generating a Has instance for the String Kind?

How (within the private module) to desugar a call to get (or dot notation) to 
use MyPrivateLabel?

And record update?

(Remember that unlike DORF, SORF's field access is syntax-directed: it 
desugars dot notation to a hard-coded String Kind for the field. There's no 
clear proposal for record update as yet)

>     ...  If everyone finds this agreeable (and I can
>     imagine no reason they wouldn't!) ...

That's a misleading remark: you're asking people to agree to a half-baked and 
sketchy proposal.

I do not "find this agreeable", and I think I've put forward heaps of reasons 
to disagree.

I expect you to:
* explain what changes you're proposing to existing syntax
* detail how to desugar that syntax to available Haskell
* detail the existing syntax you're going to desugar differently
* ideally build a prototype to prove it
* demonstrate in the prototype how the namespace control works

Then we can hold the beauty pageant.

(Oh yes: and explain what you'd have instead of dot notation, so that we can 
fire up another syntax debate ;-)


More information about the Glasgow-haskell-users mailing list