<div dir="ltr"><div>Your 1) is a very erudite way of saying "you forgot about my 'constraints' package" :) Which I did. Although it's just a little more awkward syntactically to write `(a :- b) -> whatever` instead of `(a |- b) => whatever`, which is only possible with a GHC extension, it obviously solves the problem of using constraints of the form `c1 implies c2`, i.e. 0-ary constraint functions. If I understand you correctly, you are saying that an internal entailment operator is consistent with the other workings of constraints, and pointing out the concepts that need to be handled in implementing this in GHC?<br><br>Re 2): I am probably missing something when I think that `type (c1 :: * -> Constraint) ::- (c2 :: * -> Constraint) = forall a. (c1 a :- c2 a)` works for 1-ary entailment; for instance `Sub Dict :: Ord ::- Eq` appears not to bother ghci.</div><div><br></div><div>3) It would be neat, for sure, to have this sum type. Is that the full extent of boolean logic you can define on Constraint without losing thinness?<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 27, 2017 at 11:17 AM, Edward Kmett <span dir="ltr"><<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Just a few old observations I've made from implementing these things into type systems of my own:</div><div><br></div>1.) An internal hom for the category of constraints is admissible:<div><br></div><div>(|-) :: Constraint -> Constraint -> Constraint</div><div><br></div><div>models entailment, and effectively brings into scope a local rule, but global instance resolution isn't lost if this is only produced from existing instances.</div><div><br></div><div>To your point, this is analogous to the (:-) :: Constraint -> Constraint -> * external hom for the category of constraints provided by my constraints package, but it is internal, with all of the appropriate CCC operations.</div><div><br></div><div>2.) Quantification over constraints is also admissible.</div><div><br></div><div>Neither one compromises the "thinness" of the category of constraints that provides us global coherence of instance resolution</div><div><br></div><div><div>In this case the property that if D is thin, so is [C,D]. forall here can quantify over any other kind you want.</div></div><div><br></div><div>Unfortunately, neither implemented in Haskell.</div><div><br></div><div>You'd need both of them to be able to talk about constraints like (forall a. Eq a |- Eq (f a)). </div><div><br></div><div>Together could eliminate, morally, the entire Data.Functor.Classes mess. (That said, as implemented those classes are a bit stronger than the quantified form)</div><div><br></div><div>3.) Constraint also admits a sum type, (\/) but it acts more like a least upper bound than an either.</div><div><br></div><div>It is much easier to talk about in the category of constraints using the first part above.</div><div><br></div><div>Given (p |- r, q |- r), (p \/ q) |- r and vice versa.</div><div><br></div><div>The key to keeping the category of constraints thin is that you can't case analyze on it, its more like if you look at, say, Ord [a] \/ Eq a you can get to any constraint that you could get to given the intersection of both, not using the particulars of either. e.g. its morally as powerful as Eq [a] in this case.</div><div><br></div><div>Getting this stuff into GHC is the tricky part!</div><div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Dec 27, 2017 at 2:50 AM, Ryan Reich <span dir="ltr"><<a href="mailto:ryan.reich@gmail.com" target="_blank">ryan.reich@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr"><div>The Constraint kind appears to lack an interface to an important capability that is already part of the type checker: constraint implication. Namely, the ability to provide a witness for the statement "constraint c1 implies constraint c2" or, more importantly, "for all a, constraint (c1 a) implies constraint (c2 a)", where c1 and c2 are now constraint-valued type functions (and possibly even for constraint functions with multiple parameters). It seems to me that this can follow the pattern of the "magic" Coercible type class and the (non-magic) Coercion data type; it provides the programmer with an analogous value to this example that can be obtained in apparently no other way.<br></div></div>
<br></span>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>