PROPOSAL: Include record puns in Haskell 2011
Simon Peyton-Jones
simonpj at microsoft.com
Thu Feb 25 03:33:47 EST 2010
| >> we implicitly get
| >> f :: T -> Int
| >> which punning shadows with
| >> f :: Int
| >> whereas I generally avoid shadowing completely.
| >
| > I agree with Ian.
|
| I tend to agree.
I originally had field puns in GHC, and then took them out when Haskell 98 removed them, after a discussion very like this one. I put them back in because some people really wanted them.
Actually GHC has three separate extensions to do with named fields:
field disambiguation (Section 7.3.14)
field puns (Section 7.3.15)
field wildcards (Section 7.3.16)
Look here http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#disambiguate-fields
Opinions differ. I'm rather with John: let the programmer choose, rather than enforcing a style in the language. For punning, the programmer can certainly choose on a case by case basis. If you use Haskell 98's existing syntax, there is no change to the semantics if you switch on field puns:
data T = C { f :: Int }
foo (C {f = x}) = ... -- No punning
bar (C {f}) = ... -- Punning
It would help this discussion if someone created a ticket to explain the actual proposal, so that we are all discussing the same thing.
Simon
More information about the Haskell-prime
mailing list