<div dir="auto"><div>Yep, agreed. Totally practical.<div dir="auto"><br></div><div dir="auto">FYI: my code base at work seems quite happy with the IsTrue approach; a very happy simplification! Like so:</div><div dir="auto"><br></div><div dir="auto">```</div><div dir="auto">class IsTrue</div><div dir="auto">  (msg :: ErrorMessage) (b :: Bool) where</div><div dir="auto">  isTrue :: Proxy# msg -> b :~: 'True</div><div dir="auto"><br></div><div dir="auto">instance IsTrue msg 'True where</div><div dir="auto">  isTrue = \_ -> Refl</div><div dir="auto"><br></div><div dir="auto">instance TypeError msg => IsTrue msg 'False</div><div dir="auto">  isTrue = \_ -> error "impossible"</div><div dir="auto"><br></div><div dir="auto">type (<=) n m = IsTrue (Msg n m) (n GHC.TypeLits.<=? m)</div><div dir="auto"><br></div><div dir="auto">type Msg (n :: Nat) (m :: Nat) =</div><div dir="auto">    'ShowType n</div><div dir="auto">  ':<>:</div><div dir="auto">    'Text " is not <= "</div><div dir="auto">  ':<>:</div><div dir="auto">    'ShowType m</div><div dir="auto">```</div><div dir="auto"><br></div><div dir="auto">(An `absurd` for TypeError might be nice?</div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif">Via isTrue, I can explicitly convert between the two <= constraints wherever I need to. Which I could use to explicitly manage those hypothetical hypotheticals we were discussing.</span><br></div><div dir="auto"><br></div>Just to spell it out: the SMT solver would indeed supercede TcTypeNats, but TcTypeNats in turn already supercedes the IsTrue-based encoding. So I've already lost some <= deductions. But my work code doesn't use any of them in this middle ground -- they're all simple enough that IsTrue works as-is or complicated enough that TcTypeNats didn't work already (I'm grumpily writing and invoking Trusted Code Base "axia" in those cases -- I'm avoiding plugin dependencies at work for now.)<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 21, 2019, 09:14 Richard Eisenberg <<a href="mailto:rae@richarde.dev">rae@richarde.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">You're right that, without special support, the IsTrue approach won't work with any deductions from Givens. But -- short of strapping on an SMT solver -- we're always going to fall short there, so we should analyze a particular on-the-ground use case before taking any drastic action. (It sounds like you agree with this.)<div><br></div><div>Richard<br><div><br><blockquote type="cite"><div>On May 21, 2019, at 5:52 PM, Nicolas Frisby <<a href="mailto:nicolas.frisby@gmail.com" target="_blank" rel="noreferrer">nicolas.frisby@gmail.com</a>> wrote:</div><br class="m_5437780149369474224Apple-interchange-newline"><div><div dir="auto"><div dir="auto">Yes, it seems possible that a user space declaration of <= via IsTrue as in my first email could get much of the desired behavior. I plan on trying it with the work code base soon, maybe even today -- it'll probably do better than my current workaround.</div><div dir="auto"><br></div><div dir="auto">If, however, we want the Nat solver to do anything at all with a Given `IsTrue (n <=? m)`, then I think it will need changes. I don't know that machinery well, but it seems very likely it would ignore such Givens.</div><div dir="auto"><br></div><div dir="auto">For example, I would naively expect the Nat solver should discharge a Wanted `IsTrue (n <=? m)` from two Givens `(IsTrue (n <=? x),IsTrue (x <=? m))`.</div><div dir="auto"><br></div><div dir="auto">Simon's exploration of IsTrue/IsEqual might shed more light on what exactly the Nat solver should and should not do with such a Given. If it's in fact nothing at all, then yes, maybe a user space solution fully supplants the proposed Passive.<=. But I currently anticipate that it should do something with such Givens.</div><div dir="auto"><br></div><div dir="auto">Thanks. -Nick</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 21, 2019, 00:29 Richard Eisenberg <<a href="mailto:rae@richarde.dev" rel="noreferrer noreferrer" target="_blank">rae@richarde.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is an interesting proposal. When I started reading it, I wondered why anyone would want to avoid the current definition. But you motivate that part well. I would want a larger test of the IsTrue approach to make sure it does what you want before supporting this. But wait: couldn't you write your GHC.TypeLits.Passive today, in a library, with no ill effect? If so, there isn't a strict reason GHC needs to adopt this. (Of course, if the new definition proves useful, then it might make sense to do so in time.)<br>
<br>
> On May 21, 2019, at 3:48 AM, Nicolas Frisby <<a href="mailto:nicolas.frisby@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">nicolas.frisby@gmail.com</a>> wrote:<br>
> <br>
> P.P.S. - Is there a standard place to find something like `IsTrue`? More generally: a test for type equality that does not drive unification? Thanks again.<br>
<br>
If something like this ends up in GHC, Data.Type.Bool seems like the right place.<br>
<br>
Richard</blockquote></div>
</div></blockquote></div><br></div></div></blockquote></div></div></div>