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

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

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

One or more:

5条回答
  •  再見小時候
    2020-12-01 07:52

    The regex-applicative package defines a custom many method for the RE (regular expression) type. Regular expressions, and therefore RE parsers, must be finite in size, so using default definitions for both some and many would lead to infinite loops! Fortunately, many is just the classic regular expression *.

    The package also includes a definition of some, but that looks too much like the default definition to be anything interesting.

提交回复
热议问题