2

我想这样做:

findFirst :: Parser a -> String -> Maybe a
findFirst parser text = 
    search (maybeResult . parse parser . pack $ text) text where
            search _ []       = Nothing 
            search Nothing  _ = findFirst parser (DL.drop 1 text)  
            search res _      = res 

它工作正常,但在 attoparsec 的世界中是否有更简单(更美观)的方式?

4

0 回答 0