使用attoparsec Haskell库查找字符串中第一次解析成功的最佳方法

使用attoparsec Haskell库查找字符串中第一次解析成功的最佳方法,haskell,attoparsec,Haskell,Attoparsec,我想这样做: 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 tex

我想这样做:

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 

它工作得很好,但是在Atoparsec的世界里有没有一种更简单(更漂亮)的方法?

这个问题似乎是离题的,因为它是关于改进已经工作的代码的。最好是在星期六收到。