<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">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.<div class=""><br class=""></div><div class="">So, may I propose a slightly different way forward?</div><div class=""><br class=""></div><div class="">Instead of adding a HasCallStack constraint on these functions, add an IsPartial constraint. For example:</div><div class=""><br class=""></div><div class="">> head :: IsPartial => [a] -> a</div><div class=""><br class=""></div><div class="">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:</div><div class="">* IsPartial is declarative: it describes a property of the function without worrying about its operation.</div><div class="">* If we think about the way constraints propagate, IsPartial has the right semantics: the caller of a partial function would itself become partial.</div><div class="">* We have some room in how we relate IsPartial to HasCallStack. We could say that IsPartial is just a synonym for HasCallStack (e.g. with type IsPartial = HasCallStack). But perhaps better would be to somehow give users control over whether they want the HasCallStack mechanism to be able to solve IsPartial constraints. Maybe some users would prefer not to be able to satisfy IsPartial constraints immediately, but instead to require an acknowledgement in their code that they're doing something partial. For example:</div><div class=""><br class=""></div><div class="">partialityIsOK :: String -> (IsPartial => r) -> r</div><div class="">elements xs = map (partialityIsOK "lists returned by `group` are always non-empty" head) (group xs)</div><div class=""><br class=""></div><div class="">The partialityIsOK function has a more involved type than I would like, but it's very usable in practice. Of course, such a thing only makes sense if IsPartial cannot automatically be satisfied. Getting this to work properly probably needs an extra language feature (maybe make IsPartial magically built-in?), but it might provide a declarative, yet operationally practical way forward here.</div><div class=""><br class=""></div><div class="">Richard</div><div class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 6, 2021, at 12:49 PM, Dominic Steinitz <<a href="mailto:dominic@steinitz.org" class="">dominic@steinitz.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">-1 for the reasons Henrik has listed<div class=""><br class=""><div class="">
<div 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;" class="">Dominic Steinitz<br class=""><a href="mailto:dominic@steinitz.org" class="">dominic@steinitz.org</a><br class=""><a href="http://idontgetoutmuch.org" class="">http://idontgetoutmuch.org</a><br class="">Twitter: @idontgetoutmuch</div>

</div>
<div class=""><br class=""><blockquote type="cite" class=""><div class="">On 5 Jun 2021, at 11:10, <a href="mailto:libraries-request@haskell.org" class="">libraries-request@haskell.org</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" 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="">Re: RFC: Add HasCallStack constraint to partial Data.List</span><br 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;" 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="">     functions.</span></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">Libraries mailing list<br class=""><a href="mailto:Libraries@haskell.org" class="">Libraries@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries<br class=""></div></blockquote></div><br class=""></div></div></body></html>