
that's solvable with CPP if needed
Note that it's possible to avoid CPP because one can use `fmap toList
. some` to achieve the old behavior. And the breakage is not silent,
so it won't be too hard for maintainers.
On Sun, Mar 5, 2017 at 2:49 PM, Ivan Lazar Miljenovic
On 5 March 2017 at 21:51, Vladislav Zavialov
wrote: 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.
The disadvantage is also for people trying to maintain a code base, though that's solvable with CPP if needed.
However, this also affects the default instances.
(As a user and implementor of Alternative instances, I've never found myself at a disadvantage for using the current type.)
I volunteer to implement. Does everyone agree it's a good idea?
I'm -0.5.
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com http://IvanMiljenovic.wordpress.com