[Haskell-cafe] Splitting off many/some from Alternative

Ross Paterson ross at soi.city.ac.uk
Thu Dec 15 04:03:17 CET 2011


On Thu, Dec 15, 2011 at 02:36:52AM +0000, Antoine Latter wrote:
> This seems to generalize to list:
> 
>     some [] = []
>     some xs = [cycle xs]
> 
>     many [] = [[]]
>     many xs = [cycle xs]

More like

    some [] = []
    some (x:xs) = repeat (repeat x)

    many [] = [[]]
    many (x:xs) = repeat (repeat x)

> Although I'm still not sure why I would be using these operations in
> maybe or list.

That's true.



More information about the Haskell-Cafe mailing list