serokell / universum

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

Add function to express list operations through 'NonEmpty' #145

Open chshersh opened 6 years ago

chshersh commented 6 years ago

Add this function:

safe f = fmap f . nonEmpty

We export some functions to work with NonEmpty. But sometimes we want functions to work with [] and return Maybe. All such functions can be expressed through nonEmpty function. So it's nice to have such combinator. Also, safeHead can be safely removed.

int-index commented 6 years ago

Bad name.

chshersh commented 6 years ago

@int-index I was thinking on viaNonEmpty but this is too long. Propose better name.

int-index commented 6 years ago

Not too long.