In a recent message Sebastian Hunt suggests a solution to the 'newtype'
problem. Let me recall another approach which can cure several things at a
time (probably introducing new problems though).

Some time ago Mark Jones wrote a paper " From Hindley-Milner Types to
Modular Structures". He suggested introducing record types like

  type Point = {x,y: Real}

If we define records to be unlifted then the type Int and {int: Int}
will be isomorphic and there is no reason to introduce a special 'newtype'
syntax. There is a problem with class instances - type synonyms are not
allowed there. May be, the restriction could be relaxed to allow
types defined as structures to be subject to instantiating.

It's worth noting that with Mark's ideas the records of the 1.3 proposal
can be replaced by something more general - another step forward.

I don't like neither 'newtype' nor the records of Haskell 1.3. Both mean a
lot of syntax with little semantics. Even if Mark's ideas seem premature at
this stage it's worth working on them and not introducing some bad syntax
to be withdrawn from the language later. Removing even the worst syntax
>from a language is always a painful process, vide the n+k patterns.

Rysiek

PS. I've written the above without Mark's permit. Sorry, Mark, it was too
difficult for me to wait...

 

 




Reply via email to