Re: RFC: Add HasCallStack constraint to partial Data.List functions.
Henning Thielemann <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.libraries |
|---|---|
| Message-ID | <[email protected]> |
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.
_______________________________________________
Libraries mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries