Typechecker plugins: request for review and another workflow question

Adam Gundry adam at well-typed.com
Mon Nov 10 09:31:51 UTC 2014


Hi Iavor,


On 10/11/14 00:17, Iavor Diatchki wrote:
> Hello,
>
> I just finished merging HEAD into the branch implementing constraint
> solver plugins (`wip/tc-plugins`), so things should be fully up to
> date.  For ease of review, I squashed everything into a single commit:
>
> https://github.com/ghc/ghc/commit/31729d092c813edc4ef5682db2ee18b33aea6911
>
> could interested folks (I know of SimonPJ, Richard, and Adam) have a
> look and let me know if things look reasonable?

Thanks, this is fantastic work! It will be great to see this in HEAD and
7.10. I've been tracking your branch for a while to build my plugin for
units of measure, and I'm happy to report that it is nearly working...

On the subject of that "nearly", I'm interested to learn whether you
have a suggestion to deal with unflattening, because the interface still
works with flat constraints only. Simon's changes should make it more
practical to unflatten inside the plugin, but it would be far easier (at
least for my purposes) if it was simply given unflattened constraints. I
realise that this would require the plugin loop to be pushed further
out, however, which has other difficulties.

A few other issues, of lesser importance:

 * I still think it would be better to provide an escape hatch to the
TcS, not merely the TcM, alongside the nice TcPluginM wrapper. Notably,
Simon's new TcFlatten.unflatten needs TcS...

 * Is there a way for my plugin to "solve" a given constraint (e.g. to
discard the uninformative "a * 1 ~ a")?

 * It is unfortunately easy to create infinite loops by writing plugins
that emit wanteds but make no useful progress. Perhaps there should be a
limit on the number of times round the loop (like SubGoalDepth but for
all constraints)?

 * Perhaps runTcPlugin should skip invoking the plugin if there are no
wanteds?

 * The use of ctev_evar in runTcPlugin is partial, and fails with a
nasty error if the plugin returns a non-wanted in the solved constraints
list. Would it be worth catching this error and issuing a sensible
message that chastises the plugin author appropriately?

 * Finally, I presume the comment on runTcPlugin that "The plugin is
provided only with CTyEq and CFunEq constraints" is simply outdated and
should be removed?

Apologies for the deluge of questions - please take them as evidence of
my eagerness to use this feature!

All the best,

Adam


-- 
Adam Gundry, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com/


More information about the ghc-devs mailing list