[Haskell] Per-type function namespaces (was: Data.Set whishes)

Andreas Rossberg rossberg at ps.uni-sb.de
Thu Mar 4 10:52:51 EST 2004

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 #.


	- Andreas

Andreas Rossberg, rossberg at ps.uni-sb.de

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

More information about the Haskell mailing list