RFC: Add HasCallStack constraint to partial Data.List functions.
Henning Thielemann
lemming at henning-thielemann.de
Fri Jun 4 20:57:51 UTC 2021
On Fri, 4 Jun 2021, Henrik Nilsson wrote:
> And besides those, there are other perfectly reasonable functions like
> (!!) and foldr1 that I'd definitely would not say never should be used,
> just as I would not say that array indexing or integer divisions must be
> shunned because they are partial.
I prefer to replace (xs!!k) by
case drop k xs of
[] -> defaultX
x:_ -> x
or do not use indexing on lists, at all, because of performance reasons. I
use foldr1 only on non-empty lists.
Division by non-zero divisors would be nice to have, but currently we can
only have it with Liquid Haskell.
More information about the Libraries
mailing list