<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 30, 2020, at 3:50 PM, Christiaan Baaij <<a href="mailto:christiaan.baaij@gmail.com" class="">christiaan.baaij@gmail.com</a>> wrote:</div><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">It seems like a function like `rewritePlugin` is something we could/should just build on top of the existing plugin mechanism, and have something along the line of:<br class=""></div><div class=""><br class=""></div><div class="">> -- | Create a 'TcPluginSolver' from the provided rewrite function<br class=""></div><div class="">> rewritePluginSolver ::</div><div class="">> (s -> TyCon -> [TcType] -> TcPluginM (Maybe TcType)) -> <br class=""></div><div class="">> (s ->
<a id="gmail-t:TcPluginSolver" class="gmail-def">TcPluginSolver)</a>
</div><div class=""><br class=""></div><div class="">where `rewritePlugin` just traverses constraints with the given rewrite and creates the evidence, emits new wanteds, etc.</div><div class="">(We could develop such a function outside of the `ghc` package, and only once we have a satisfactory solution, perhaps consider it for inclusion in the `ghc` package.)</div><div class="">This way, we won't have to make the common case of simplifying type families slow, and still provide a straightforward API.<br class=""></div></div></div></blockquote><br class=""></div><div>Ooh. I like that idea. Much more orthogonal than mine. It would mean, though, that a plugin that needs to reduce lots of type families is slower than it needs to be. (That is, my idea is slower in the common case of doing most type family reduction within GHC, but faster in the case where more type family reduction is done by plugin.) In any case, it would make a nice stepping stone for the future.</div><div><br class=""></div><div>If you (for any value of you) get all the infrastructure settled, I'll happily contribute the implementation of that particular function. It would be nice if the infrastructure allows me to test, as I'll surely get it wrong a few times before getting it right.</div><div><br class=""></div><div>Richard</div><br class=""></body></html>