<!doctype html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body>Yeah, I think a typeclass to express partiality is a sloppy technique. I'm not even sure everyone agrees on what 'partial' means: if my function throws an IO error on relative FilePaths, is it partial? Is all IO partial?<br><br>Haskell is definitely not a total language and I doubt it will be. I also don't think that it's an interesting goal. It requires a considerable shift in language design.<br><br>HasCallstack sounds like a pragmatic solution, but you could as well create an alternative prelude that adds it everywhere you want and then avoid implicit prelude. That won't help you with unsound dependencies, that don't use it, but it's opt-in, which seems more reasonable given that it's obviously a somewhat controversial change.<br><br>I'd expect the nay-sayers here, however, to be a driving force in a better GHC based solution. Otherwise, the next time this comes up people will say "you had time enough".<br><br><div class="gmail_quote">On June 8, 2021 6:10:52 PM UTC, Oliver Charles <ollie@ocharles.org.uk> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><br></div><div><br></div><div>On Tue, 8 Jun 2021, at 6:36 PM, Richard Eisenberg wrote:<br></div><blockquote type="cite" id="qt" style="overflow-wrap:break-word;"><div>I've been very much of two minds in this debate: On the one hand, having these constraints is very practically useful. On the other, what we're doing here is very un-Haskellish, in that we're letting operational concerns leak into a declarative property (a function's type). The reason we're doing this is another un-Haskellish thing -- partiality -- but that ship has sailed.<br></div><div class="qt-"><br></div><div class="qt-">So, may I propose a slightly different way forward?<br></div><div class="qt-"><br></div><div class="qt-">Instead of adding a HasCallStack constraint on these functions, add an IsPartial constraint. For example:<br></div><div class="qt-"><br></div><div class="qt-">> head :: IsPartial => [a] -> a<br></div><div class="qt-"><br></div><div class="qt-">This is slightly awkward, still, because IsPartial is a class-constraint-like-thing, but it has no parameter. But it has a few very nice properties:<br></div><div class="qt-">* IsPartial is declarative: it describes a property of the function without worrying about its operation.<br></div><div class="qt-">* If we think about the way constraints propagate, IsPartial has the right semantics: the caller of a partial function would itself become partial.<br></div></blockquote><div><br></div><div>I don't think this is true.<br></div><div><br></div><div>Take:<br></div><div><br></div><div>foo :: Int -> Bool<br></div><div>foo _ = head [True]<br></div><div><br></div><div>Clearly foo is total - it is defined for all of its inputs. That it uses a partial function in its body isn't observable. So it's a shame that IsPartial leaks out.<br></div><div><br></div><div>I guess here you'd have me say<br></div><div><br></div><div>foo _ = partialityIsOk $ head [True]<br></div><div><br></div><div>?<br></div><div><br></div><div>Ollie<br></div></blockquote></div></body></html>