PROPOSAL: deprecate field labels as selectors (was Include field label puns in Haskell 2011

Anthony Clayden anthony_clayden at clear.net.nz
Thu Feb 25 20:55:58 EST 2010


>Isaac Dupree <ml at ...> writes:
> On 02/24/10 13:40, Martijn van Steenbergen wrote:
> > Ian Lynagh wrote:
> >> I have a feeling I'm in the minority, but I find record punning an ugly
> >> feature.
> >>
> >> Given
> >> data T = C { f :: Int }
> >> 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.
> 
> <snip>
> 
> -Isaac
> 

(I know how you're always looking for things to take out of
Haskell ...)

I can see the ugliness of having a name with two
incompatible types (especially in the same scope).

I wonder: if a programmer from Mars landed into Haskell a la
GHC 2010 (that is, unburdened by history back to v1.3),
wouldn't it be the scare-quotes 'implicit' field selector
that seems the odd man out?

After all, the program text declares { f :: Int }, and in
all uses of the field label apart from selecting, it _is_ an Int.
Where does this function thing come from?

By the way, it seems you can arrive at the same
level of confusion like this (declared in a distinct scope):

> f (C { f }) = f            -- f :: T -> Int

- Anthony






More information about the Haskell-prime mailing list