Hello all,

In response to my post on coercions in Haskell several people told 
me: Don't do it; Haskell's type system is complicated enough as it 
is, and coercions give a lot of trouble without many advantages.

Still, I wonder if the properties of type synonyms could be 
described in terms of coercions.  One could consider a type T 
introduced by a type synonym to be distinct from its defining type 
U.  To compensate for this, if an expression of type U occurs 
where one of type T is expected, or vice versa, then silently a 
coercion is inserted.  As far as I can see, the resulting 
behaviour is identical to the current Haskell "type synonym and 
its definition are completely interchangeble" rule.

If I understand `newtype' declarations correctly, viewed in this 
light they are similar to `type' declarations, except that the 
programmer is forced to name the coercion from the old to the new 
type (as a constructor), and write it down explicitly.

So, three questions:

- Is the above view of type synonyms really equivalent to the 
Haskell report's definition?

- If so, wouldn't it be a better alternative which allows the 
introduction of more general coercion functions later?

- Can it be used to replace or simplify the notion of `newtype'?  
(Why were `newtype' declarations introduced in the first place?)

Groetjes,


  <><

Marnix
--
Marnix Klooster
[EMAIL PROTECTED]   //   [EMAIL PROTECTED]



Reply via email to