label syntax vs DisambiguateRecordFields

Alex Jacobson alex at alexjacobson.com
Wed Nov 21 17:02:44 EST 2007


Nice feature but feel like a band-aid.  In particular it makes SYB style 
programming more difficult because field labels aren't types.

Almost every other record syntax plan involves field labels as types so 
you can do interesting type dispatch.

With this syntax, there is increasing probability that salary becomes a 
standard field name rather than a type.

What would be really much more useful would be an alternative newtype 
syntax like this:

   label Salary = salary::Float deriving Show

which would be equivalent of

   newtype Salary = Salary Float deriving Show
   salary (Salary x) = x

Does this make sense?

-Alex-

Tracking these open issues:
* too many pragma declarations
* recursive deriving
* labels
* : for reload in ghci
* not reloading all the modules on :r










Simon Peyton-Jones wrote:
> | So what is DisambiguateRecordFields?
> 
> It's documented in the user manual (for the HEAD):
> 
> http://www.haskell.org/ghc/dist/current/docs/users_guide/syntax-extns.html#disambiguate-fields
> 
> Simon
> 
> | -----Original Message-----
> | From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell-
> | users-bounces at haskell.org] On Behalf Of Alex Jacobson
> | Sent: 21 November 2007 20:26
> | To: Johannes Waldmann
> | Cc: glasgow-haskell-users at haskell.org; Simon Marlow
> | Subject: Re: suggestion: add a .ehs file type
> |
> | So what is DisambiguateRecordFields?
> |
> | -Alex-
> |
> | Johannes Waldmann wrote:
> | > Alex Jacobson wrote:
> | >
> | >> [...][ 50 language pragmas with arbitrary spellings [...]
> | >
> | > Indeed.
> | >
> | > For instance, I always get an error for  -XMultiParameterTypeClasses .
> | >
> | > (Without looking at the documentation: do you see why?)
> | >
> | >
> | > PS: indeed I just checked the docs and found  -XDisambiguateRecordFields
> | > Was this advertized? It seems that's what I've been missing for years.
> | >
> | > Best regards, Johannes.
> |
> | _______________________________________________
> | Glasgow-haskell-users mailing list
> | Glasgow-haskell-users at haskell.org
> | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



More information about the Glasgow-haskell-users mailing list