The ConstraintsB class was defining an associated type ConstraintsOf that one could use to get constraints of the form c (f a). We now use a more general mechanism and make ConstraintsB a type alias for backwards compatiblity.
The way things now work is as follows:
ConstraintsB has an associated type AllB c b. Given a constraint-constructor c and a barbie b it will produce a constraint (c x1, c x2, ... c xn) for each type xi under an f in b.
How do we plug an f as ConstraintsOf used to do? The trick is to define the following class, along with its universal instance:
class c (f a) => ClassF c f a
instance c (f a) => ClassF c f a
And now ConstraintsOf c f b becomes essentially AllB (ClassF c f) b.
Actually, for barbies defined with Wear, ConstraintsOf c f b was also adding constraints of the form (Wear f x1 ~ f x1,... Wear f xn ~ f xn). We add a second associated type to 'ConstraintsB, called 'NotBare b fthat builds this constraint onWear-barbies and()` otherwise.
Credit goes to Csongor Kiss for this very nice formulation.
The
ConstraintsB
class was defining an associated typeConstraintsOf
that one could use to get constraints of the formc (f a)
. We now use a more general mechanism and makeConstraintsB
a type alias for backwards compatiblity.The way things now work is as follows:
ConstraintsB
has an associated typeAllB c b
. Given a constraint-constructorc
and a barbieb
it will produce a constraint(c x1, c x2, ... c xn)
for each typexi
under anf
inb
.How do we plug an
f
asConstraintsOf
used to do? The trick is to define the following class, along with its universal instance:And now
ConstraintsOf c f b
becomes essentiallyAllB (ClassF c f) b
.Actually, for barbies defined with
Wear
,ConstraintsOf c f b
was also adding constraints of the form(Wear f x1 ~ f x1
,... Wear f xn ~ f xn). We add a second associated type to 'ConstraintsB
, called 'NotBare b fthat builds this constraint on
Wear-barbies and
()` otherwise.Credit goes to Csongor Kiss for this very nice formulation.