<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><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></body></html>