[Haskell-cafe] Type Families
Felipe Lessa
felipe.lessa at gmail.com
Sun Sep 20 22:19:17 EDT 2009
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.
More information about the Haskell-Cafe
mailing list