
2 Dec
2013
2 Dec
'13
5:28 p.m.
TP wrote:
propagate :: Bar -> (forall a. (FooClass a) => a->a) -> Bar
In fact, I do not understand why we have to add the typeclass constraint (FooClass a). Indeed, there is no mention to foo1 and foo2 functions (members of the FooClass typeclass) in the code of propagate: ------- propagate v f = case v of Bar1 i -> Bar1 (f i) Exp1 b1 b2 -> Exp1 (propagate b1 f) (propagate b2 f) Exp2 b1 b2 -> Exp2 (propagate b1 f) (propagate b2 f) ------- propagate deals with any function a priori, not only foo1 and foo2. So how to understand the need for this typeclass constraint? TP