Haskell: some and many [duplicate]

筅森魡賤 提交于 2019-12-04 17:43:08

问题


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:


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.



来源:https://stackoverflow.com/questions/5841511/haskell-some-and-many

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!