And this is only tip of the iceberg.

Now we have discussion about

(Monad m) vs. (Functor m => Monad m).

With class interfaces it is not an option: we have them both(!!!)


{{{

class Monad m where ...

class Functor m => Applicative m => Monad m where ..

}}}


Let's see how it could work:


We have
{{{
class Num a where
(+), (*) :: a -> a -> a
(-) :: a -> a -> a
negate :: a -> a
fromInteger :: Integer -> a
}}}

Let we also have

{{{

class Additive a where
plus :: a -> a -> a
zero :: a

class Additive a => AdditiveNegation a where
minus :: a -> a -> a
negation :: a -> a
x `minus` y = x `plus` negation y

class Multiplicative a where
multiply :: a -> a -> a
one :: a

class FromInteger a where
fromInteger' :: Integer -> a

}}}

Now we wish to unite both of them

For example, we could also define next:


{{{
class (Additive a,
Additive a => AdditiveNegation a,
Multiplicative a, FromInteger a) => Num a where
(+) = plus
(*) = multiply
(-) = minus
negate = negation
fromInteger = fromInteger'



class (Num a) => Additive a where
plus = (+)
zero :: a
default zero :: () => Additive a => a
default zero = zero

class (Num a) => AdditiveNegation a where
minus = (-)
negation = negate


class (Num a) => Multiplicative a where
multiply = (*)
one :: a
default one :: () => Multiplicative a => a
default one = one

class (Num a) => FromInteger a where
fromInteger' = fromInteger
}}}


Wvv  



View this message in context: RE: Re: Interfaces - the Golden Path of Haskell?
Sent from the Haskell - Haskell-prime mailing list archive at Nabble.com.