> instance ( Evaluate a
> , Evaluate b
> ) => Evaluate (Add a b) where
> data Value (Sum a b) = SumValue (Sum a b)
Even this much is straightforward. We require a and b to be Evaluate'able before we can find the sum of a and b as "values". Now I want to write my definition for the "value" function. But... how is that supposed to work? My first guess is
value (SumValue (Sum a b)) = (value a) + (value b)
But I more-or-less expected that to fail. I realize I need some more typing information. What am I supposed to fill in? My next guess was
> value (SumValue (Sum a b)) = (value $ Value a) + (value $ Value b)
But Value doesn't exist as a type constructor. So now that I am starting to "get" what's going on, I wonder why I don't get what's going on. Since I need to use a type constructor for the (Value a) and (Value b) "things", it kind of defeats the point. (I hesitate to say "value", since I have been using "value" to mean the result/blah of an Evaluate instance)
Speaking of which, I am still not sure what the difference between associate data type families and associated type constructor families are. The former use the data keyword in class declarations, and the latter use type keywords. What can I do with one and not the other?
I would really appreciate some guidance.
Thanks!
Alex