
Den 2015-06-19 22:13, Leza Morais Lutonda skrev:
Note this won't work for a Num instance mentioned earlier because the existentially quantified d types in two SC values are not provably the same type. In other words, you can't write
instance Num e => Show (S Num e) where SC x1 y1 + SC x2 y2 = SC (x1 + x2) (y1 + y2)
because x1 and x2 can have different types. Another issue is: what if I want to constraint the type `e` to more classes and make `d` to have the same constrains? I have to re-declare
On 06/19/2015 08:44 AM, Sean Leather wrote: the `S` data type like?:
data S c1 c2 ... cN e where
SC :: (c1 d, c2 d, ..., cN d) -> d -> e -> S c1 c2 ... cN e
Does anyone ever needed such a feature?
Yes, have a look at the paper "Deconstraing DSLs": http://dl.acm.org/citation.cfm?id=2364571 See also the constraint product (&&&) from the `constraints` package. / Emil