What are Alternative's “some” and “many” useful for?

后端 未结 5 2176
春和景丽
春和景丽 2020-12-01 07:31

Alternative, an extension of Applicative, declares empty, <|> and these two functions:

One or more:

5条回答
  •  粉色の甜心
    2020-12-01 08:05

    I tend to see them in Applicative parser combinator libraries.

    a :: Parser [String]
    a = some (string "hello")
    

    and I see many used for purpose in the default definitions of Parsing in parsers.

    I think Parsec being the primary example of a parser combinator library hides the use of some/many since it redefines things like (<|>).

提交回复
热议问题