In article <[EMAIL PROTECTED]>,
 Alastair Reid <[EMAIL PROTECTED]> wrote:

> One way to overcome part of this problem would be to generalize the idea of 
> 'type synonyms' to allow 'context synonyms'.  For example, we have type 
> synonyms like:
> 
>   type Point = (Int,Int)
> 
> we could have 'context synonyms' like:
> 
>   class Num a => (Add a, Subtract a, FromInteger a, Eq a, Multiply a, ...) 

That would be quite unnecessary. Simply write this:

  class (Add a, Subtract a, FromInteger a, Eq a, Multiply a, ...) =>
   Num a;
  instance (Add a, Subtract a, FromInteger a, Eq a, Multiply a, ...) =>
   Num a;

And now you can write this:

  invert :: Num a => Matrix a -> Matrix a

I use this idiom quite frequently for "joining" classes together.

-- 
Ashley Yakeley, Seattle WA

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

Reply via email to