Alternative.some and NonEmpty

Mario Blažević mblazevic at stilo.com
Tue Mar 7 16:36:47 UTC 2017


On 2017-03-06 03:39 AM, Henning Thielemann wrote:
>
> On Sun, 5 Mar 2017, 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.
>
> A less invasive way would be to add a new function with that type.

If we're adding a new function, it might make more sense to add 
something more generic, like

genericMany, genericSome ::
   (Alternative f, Applicative m, Monoid m) => f a -> f (m a)

The expected type of these operations is usually fixed on the client side.



More information about the Libraries mailing list