<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Hi Adam, Hi Eric,</div><div><br></div><div>At least for what I want to use them for [1] it would be nice if there was an easy way to say:</div><div><br></div><div>If you are stuck on solving "Constraint a b TypeC", then you should pick, e.g.:</div><div> - "a ~ TypeA" and "b ~ TypeB" (What I am actually trying to say is: use the instance "Constraint TypeA TypeB TypeC")</div><div> - "a ~ b"</div><div><br></div><div>Currently I am producing equality constraints, like this:</div><div><br></div><div><div>mkDerivedTypeEqCt :: TcTyVar -> TcType -> TcPluginM Ct</div><div>mkDerivedTypeEqCt tyVar ty = do</div><div>  (_, lclEnv) <- getEnvs</div><div>  return $ CTyEqCan </div><div>    { cc_ev = CtDerived -- :: CtEvidence</div><div>      { ctev_pred = ty -- :: TcPredType</div><div>      -- This matches type-wise, but I have no idea what actually belongs here.</div><div>      , ctev_loc = mkGivenLoc topTcLevel (UnifyForAllSkol [tyVar] ty) lclEnv -- :: CtLoc</div><div>      -- Again no idea what actually belongs here:</div><div>      --   topTcLevel :: TcLevel</div><div>      --     To what does this relate? I guess top level </div><div>      --     is ok for equality constraints</div><div>      --   (UnifyForAllSkol [tyVar] ty) :: SkolemInfo</div><div>      --     This one matches what we have at disposal (no idea if it is the right one).</div><div>      --   lclEnv :: TcLclEnv</div><div>      --     I just use the only one I know.</div><div>      }</div><div>    , cc_tyvar = tyVar -- :: TcTyVar</div><div>    , cc_rhs = ty -- :: TcType</div><div>    , cc_eq_rel = NomEq -- :: EqRel</div><div>    -- Alternative would be ReprEq. Whats the difference?</div><div>    }</div></div><div><br></div><div>Which seems to be working, but still leaves a lot of open questions (see comments).</div><div><br></div><div>Maybe my problems using the API are more related to missing documentation, then lack of API functionality.</div><div><br></div><div>Jan</div><div><br></div><div>[1]: <a href="https://mail.haskell.org/pipermail/ghc-devs/2015-February/008414.html">https://mail.haskell.org/pipermail/ghc-devs/2015-February/008414.html</a></div><div> </div><div>On <span style="font-size:12.8000001907349px">Wed, 27 May 2015 07:13:37, Eric Seidel wrote:</span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hi Adam,<br>
<br>
I like the addition of the new* functions for creating constraints, that<br>
should make for a much nicer API than dealing directly with the<br>
CtEvidence constructors!<br>
<br>
I'm not so convinced however about embedding arbitrary CoreExprs in<br>
EvTerms. First of all, it feels a bit strange to generate CoreExprs<br>
before the desugarer (and we would have to add a `MonadThings TcPluginM`<br>
instance to generate Integer and String CoreExprs).<br>
<br>
But more importantly, based on your wiki page [1], it sounds like what<br>
we really want is a nice API for creating dictionaries.<br>
<br>
Eric<br>
<br>
[1]:<br>
<a href="https://ghc.haskell.org/trac/ghc/wiki/Plugins/TypeChecker#EmbeddingCoreExprinEvTerm" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/Plugins/TypeChecker#EmbeddingCoreExprinEvTerm</a><br>
<br>
<br>
<br>
On Wed, May 27, 2015, at 01:33, Adam Gundry wrote:<br>
> Hi devs,<br>
><br>
> I thought I should flag up some proposed changes relating to typechecker<br>
> plugins, which Christiaan, Iavor and I have been discussing. The quick<br>
> summary:<br>
><br>
>  * make it possible for plugins to create constraints (Phab:D909);<br>
><br>
>  * make it easier for plugins to define special type families;<br>
><br>
>  * embed CoreExpr in EvTerm.<br>
><br>
> For more details, see the wiki page:<br>
> <a href="https://ghc.haskell.org/trac/ghc/wiki/Plugins/TypeChecker#Post-7.10changestoTcPluginMAPI" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/Plugins/TypeChecker#Post-7.10changestoTcPluginMAPI</a><br>
><br>
> Questions/review/comments very welcome.<br>
><br>
> Adam<br>
><br>
><br>
> --<br>
> Adam Gundry, Haskell Consultant<br>
> Well-Typed LLP, <a href="http://www.well-typed.com/" target="_blank">http://www.well-typed.com/</a><br>
> _______________________________________________<br>
> ghc-devs mailing list<br>
> <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br></blockquote></div></div></div>