<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></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 Mar 26, 2021, at 8:41 PM, Alexis King <<a href="mailto:lexi.lambda@gmail.com" class="">lexi.lambda@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">If there’s a single principal type that makes my function well-typed<span class="Apple-converted-space"> </span></span><i style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">and exhaustive</i><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">, I’d really like GHC to pick it.</span></div></blockquote></div><br class=""><div class="">I think this is the key part of Alexis's plea: that the type checker take into account exhaustivity in choosing how to proceed.</div><div class=""><br class=""></div><div class="">Another way to think about this:</div><div class=""><br class=""></div><div class=""></div><blockquote type="cite" class=""><div class="">f1 :: HList '[] -> ()</div><div class="">f1 HNil = ()</div><div class=""><br class=""></div><div class="">f2 :: HList as -> ()</div><div class="">f2 HNil = ()</div></blockquote><div class=""><br class=""></div><div class="">Both f1 and f2 are well typed definitions. In any usage site where both are well-typed, they will behave the same. Yet f1 is exhaustive while f2 is not. This isn't really about an open-world assumption or the possibility of extra cases -- it has to do with what the runtime behaviors of the two functions are. f1 never fails, while f2 must check a constructor tag and perhaps throw an exception.</div><div class=""><br class=""></div><div class="">If we just see \HNil -> (), Alexis seems to be suggesting we prefer the f1 interpretation over the f2 interpretation. Why? Because f1 is exhaustive, and when we can choose an exhaustive interpretation, that's probably a good idea to pursue.</div><div class=""><br class=""></div><div class="">I haven't thought about how to implement such a thing. At the least, it would probably require some annotation saying that we expect `\HNil -> ()` to be exhaustive (as GHC won't, in general, make that assumption). Even with that, could we get type inference to behave? Possibly.</div><div class=""><br class=""></div><div class="">But first: does this match your understanding?</div><div class=""><br class=""></div><div class="">Richard</div></body></html>