Simon Peyton-Jones wrote:

If the big bug-bear is record selectors, let's focus on them exclusively. I now think that ML got it right. ML records are simply labelled tuples.

Note that this is true only for SML, not for Caml.


So just as (Bool,Int) is an anonymous type, so is
{x::Bool, y::Int}.  Indeed (Bool,Int) is just shorthand for {#1::Bool,
#2::Int}.

A bit of nitpicking: (Bool,Int) would be shorthand for {1::Bool,2::Int}. In SML, labels may be numeric or alpha-numeric. OTOH, the hash is the projection operator (ASCII art for \pi), which can be used for both kinds of labels:


  #2 (x,y,z)
  #b {a=x, b=y, c=z}

Actually, #l is just syntactic sugar for (\{l=x,...}->x), which implies that you might need type annotations.

There are
no implicitly-defined record selectors either: you have to use pattern
matching for that.

Or projection using #.


Cheers,

- Andreas

--
Andreas Rossberg, [EMAIL PROTECTED]

Let's get rid of those possible thingies! -- TB

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to