Haskell Language Learning Note (parsec) (4)

Source: Internet
Author: User
Tags parse error

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.