No subject


Thu Jan 10 18:17:16 CET 2013


coercions might be added by adding special cases in the constraint solver.
It is also a reuse of syntax: we can write

foo = newtypeCast :: [Int] -> [Age]

instead of adding a new form of declaration.

_____________________

As for safety, in some sense Map a b is parametric in a and b except
the Ord instance of a. We can coerce Map a b into Map c d if
we can coerce a into c, b into d and the Ord a instance matches
Ord c instance (for example, one is derived from the other).
This could be implemented via an instance like this:

instance (a ~~ c, b ~~ d, Ord a ~~ Ord c) => Map a b ~~ Map c d

where ~~ is kind-polymorphic "equality up to newtypes".

If Map was, say, indexed (nonparametric) in the first argument,
that would be:

instance b ~~ d => Map a b ~~ Map a d

etc.

Krzysztof Gogolewski



More information about the Glasgow-haskell-users mailing list