| 1) Coerce a a can be defined as coerce=id for all a.  However, this
|    may of course lead to overlap in the type structure, so we must
|    write a separate instance definition for Coerce Int Int, Coerce
|    Double Double, etc. if we want types to be decidable.  I'd love for
|    some clever person to solve this little difficulty.

Indeed so.  And 
        instance Coerce a a where coerce = id
does not overlap with
        instance Coerce Int Bool where ...
        instance Coerce Bool Int where ...

There's no overlap here.  (Overlap = there is a Coerce t1 t2, which
matches more than one instance decl.)  Furthermore, it works fine; I
just tried it.

| 2) When we define D a b c, we know that D b a c is also allowed.
|    Again, decidability prevents us from asserting this directly.
|    Again, a clever solution could save us a lot of code and even more
|    debugging.  I suspect this may be a marginally easier nut to crack
|    than the previous one.

Much harder, I think.  Commutativity is always tricky!

Simon

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

Reply via email to