Haskell: some and many [duplicate]

2019-03-25 11:57发布

This question already has an answer here:

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条回答
我只想做你的唯一
2楼-- · 2019-03-25 12:21

They make sense, when used as a parser combinator. some means, that the parser is applied as often as possible, but at least once. many is similar, but allows no parse. In case of Maybe, Just ... never "fails", thus your parser loops.

查看更多
登录 后发表回答