Alternative.some and NonEmpty

Vladislav Zavialov vlad.z.4096 at gmail.com
Sun Mar 5 10:51:02 UTC 2017


Since 'Data.List.NonEmpty' is now in 'base', it makes sense to change
the type of 'some' from

some :: Alternative f => f a -> f [a]

to

some :: Alternative f => f a -> f (NonEmpty a)

as it's guaranteed to return a non-empty list.

Currently, both users and implementors of 'Alternative' instances are
at a disadvantage. The users have to use the unsafe NonEmpty.fromList
function to take advantage of the fact that the result of 'some' is
indeed non-empty. The implementors have more space for error - it's
possible to accidentally return an empty list.

I volunteer to implement. Does everyone agree it's a good idea?


More information about the Libraries mailing list