On Sun, Sep 20, 2009 at 06:43:53PM -0700, Alexander Solla wrote:
> > data Add a b = Add a b
> > instance ( Evaluate a
> >          , Evaluate b
> >          ) => Evaluate (Add a b) where

Okay.

> >          data Value (Sum a b) = SumValue (Sum a b)

Hmmm, have you tried

>     data Value (Add a b) = AddValue (Value a) (Value b)

Now your 'value' function would be

>     value (AddValue va vb) = value va + value vb

because you're holding 'Value a' and 'Value b', not 'a' and 'b'.


It may help to think as if this class represented a container.
For value, do you need the whole container or just one of its
elements?  I know other will give a better explanation, but maybe
this is enough to get you in the right track :).

HTH,

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

Reply via email to