Haskell: some and many

2.6k views Asked by At

What are some and many in Control.Applicative.Alternative good for? If I write something like some $ Just 42, it seems to cause infinite recursion, which seems not very useful...

1

There are 1 answers

0
fuz On BEST ANSWER

They make sense when used as parser combinators.

some means that the parser is applied as many times as possible, but at least once.

many is similar, but allows for no parse as well, returning [] in such case instead of failing.

In case of Maybe, Just ... never "fails", thus your parser some $ Just 42 loops.