On Oct 20, 2010, at 5:06 PM, Thomas Schilling <nomin...@googlemail.com> wrote:

> Do we really want to treat every newtype wrappers as a form of 'id'?
> For example:
> 
>    newtype Nat = Nat Integer   -- must always be positive
> 
> A possible rule (doesn't actually typecheck, but you get the idea):
> 
>    forall (x :: Nat). sqrt (x * x) = x
> 
> If we ignore newtyping we get an incorrect rewrite rule.  It depends
> on the exact implementation of which 'id's would be recognised.
> 

That wouldn't be generalized to id, the special treatment would only apply to 
rule that _mention_ Prelude.id explicitly.  Such rules would implicitly fire 
when, say, "fmap Nat xs" occurs because Nat would be considered a 
specialization of id in the (pattern side of) rule "fmap id = id".  Rules 
mentioning Nat would not be magical in any way.

-- James_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to