serokell / universum

:milky_way: Prelude written in @Serokell
MIT License
176 stars 26 forks source link

[#211] Safer maximum and stuff #223

Closed Martoon-00 closed 4 years ago

Martoon-00 commented 4 years ago

Description

Get rid of unsafe maximum, foldr1, and similar functions. Did it in the same way as done for head:

One thing which worries me is that now one cannot simply write something like foldr1 (+) [1..5]. Constructing NonEmpty manually is not pleasant,OverloadedLists extension is rarely used because it would break many other function calls, e.g. forM [1..5]. Not sure which solution is best here.

Related issues(s)

Fixes #211.

✓ Checklist for your Pull Request

Ideally a PR has all of the checkmarks set.

If something in this list is irrelevant to your PR, you should still set this checkmark indicating that you are sure it is dealt with (be that by irrelevance).

Related changes (conditional)

Stylistic guide (mandatory)

Martoon-00 commented 4 years ago

Note that doctest currently fails.

Mda. I guess having examples there is not so important? Too lazy to add a function which would make use of (+).

gromakovsky commented 4 years ago

I think it's not so important, but apparently you just need to add a corresponding import to the comment starting with $setup above.

Martoon-00 commented 4 years ago

Wow, that's magic. Now I see why this $setup is needed.