Parser type
data ParsecT s u m atype Parsec s u = ParsecT s u Identitytype Parser = Parsec String ()
- Data parsect s U m A
Parsect with four types of parameters: Data flow type S, User state type U, underlying monad type M, return type A.
Parsect is a monad converter.
- Type parsec s u = parsect s U Identity
The parsec type is the Parsect type, and the underlying monad type is specific to Identity.
- Type Parser = Parsec String ()
The Parser type is a special type of parsec, the data flow type is specific to String, and the user state type is null type ().
Parsetest function
parseTest :: (Stream s Identity t, Show a) => Parsec s () a -> s -> IO ()parseTest p input = case parse p "" input of Left err -> do putStr "parse error at " print err Right x -> print x
- The Parsetest function calls the parse function to parse the data stream.
- If the match fails, print an error message.
- If the match succeeds, the output returns a value.
Haskell Language Learning Note (parsec) (4)