[darcs-devel] messing around with kinds

Ganesh Sittampalam ganesh at earth.li
Thu Feb 13 06:22:00 UTC 2014


Hi,

Just to report on a failed experiment with the GHC 7.4 kind support: I
wanted to add a new kind "Context" for use with witnesses, defined as a
promoted datatype with -XDataKinds.

The kind should for example make it impossible to abuse unsafeCoerceP as
a real unsafeCoerce because it would now only coerce away type of the
Context kind (which would be guaranteed phantom).

In practice I found myself having to put kind signatures all over the
codebase to make ensure that things do get the Context kind instead of *.

Enabling the PolyKinds extension helped a bit with signatures, but not
that much in practice because things like class instances were now
expected to be polykinded and often they weren't because the
implementations required the specific Context kind. So then you have to
put a signature on the class anyway and then on the patch types that
implement the class, so it all leaked everywhere.

Also, in GHC 7.4 kinds aren't that great because you can't give kind
signatures involving kind variables, and really to make better use of
them for witnesses I think a variable would be useful to distinguish
between e.g. patch names and patch contents. This is added in GHC 7.6
and I think the inference algorithm may have changed, so I think it
would be best to try again when we can switch to that as our baseline.

Cheers,

Ganesh


More information about the darcs-devel mailing list