import Data.Attoparsec.Text.Lazy
import Data.Text.Lazy.Internal (Text)
import Data.Text.Lazy (pack)
data List a = Nil | Cons a (List a)
list :: Text
list = pack $ unlines
[ "0"
, "1"
, "2"
, "5"
]
如何实现List Int
解析器来解析Cons 0 (Cons 1 (Cons 2 (Cons 5 Nil)))
from list
?
ps:不解析 a[Int]
并将其转换为的纯解析器List Int
是可取的。