Advice about TcDeriv

Joachim Breitner mail at joachim-breitner.de
Mon Aug 19 16:19:00 CEST 2013


Hi,

to support deriving NT instances properly, TcDeriv needs to be modified.
But there are some structural obstacles: So far, all classes which had
to be had the “type of interest” as their only type argument. Therefore,
DerivSpec, the data structure in that file, carries information about
what instances to derive, in the field dc_tc :: TyCon.

But with NT it is different:
 * It has two parameters,
 * the type of interest is likely not the last parameter (e.g. NT Age Int)
 * and it can happen that there is a type variable in the last parameter
   (e.g. NT Int a => NT Age a).
All that is difficult to squeeze into the existing data structure.

The data type also has the ds_tys :: [Type] parameter, which contains
all type parameters to the class (e.g. [Int, a]). So at first I thought
about simply removing dc_tc and use the data from (last ds_tys) whenever
needed. But in the case of type families, ds_tc is not just the type
constructor of (last ds_tys), but rather what it resolves to.

So before I rewrite lots of code there, I’d like to get some advice:
Should I extend the DerivSpec to support multi-parameter-typeclasses
(and figure out how to support data families here), or rather bypass the
whole lot and handle NT instance generation separately? Or is there
maybe another, more elegant way?

Thanks,
Joachim

-- 
Joachim “nomeata” Breitner
  mail at joachim-breitner.dehttp://www.joachim-breitner.de/
  Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0x4743206C
  Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20130819/af0b5019/attachment.pgp>


More information about the ghc-devs mailing list