On 9 Apr 2008, at 15:23, Henning Thielemann wrote:
I also recognized that problem in the past, but didn't know how to solve it. In Haskell 98, methods are resolved using the types of the operands. How would the compiler find out which implementation of (+) to choose for an expression like x+y using your approach?

I might describe the idea via mangling. So if one has
  class Magma (a; unit, mult) where
    unit :: a
    mult :: a -> a -> a
then instances
  Monoid (a; 0; (+))
  Monoid (a; 1; (*))
should logically equivalent to
  Monoid_0_+ (a)
    0 :: a
    (+) :: a -> a -> a

  Monoid_1_* (a)
    1 :: a
    (*) :: a -> a -> a
or whatever internal mangling that ensures that the names Monoid_0_+ and Monoid_1_* are different.

Would this not work? - They code should be essentially a shortcut for defining new classes.

  Hans


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

Reply via email to