parsec

What's the difference between Text.ParserCombinators.Parsec and Text.Parsec

萝らか妹 提交于 2019-11-28 07:09:38
Text Text.Parsec Text.Parsec.ByteString Text.Parsec.ByteString.Lazy Text.Parsec.Char Text.Parsec.Combinator Text.Parsec.Error Text.Parsec.Expr Text.Parsec.Language Text.Parsec.Perm Text.Parsec.Pos Text.Parsec.Prim Text.Parsec.String Text.Parsec.Token ParserCombinators Text.ParserCombinators.Parsec Text.ParserCombinators.Parsec.Char Text.ParserCombinators.Parsec.Combinator Text.ParserCombinators.Parsec.Error Text.ParserCombinators.Parsec.Expr Text.ParserCombinators.Parsec.Language Text.ParserCombinators.Parsec.Perm Text.ParserCombinators.Parsec.Pos Text.ParserCombinators.Parsec.Prim Text

Why does ParsecT type have 'u' argument?

為{幸葍}努か 提交于 2019-11-28 03:33:25
问题 Documentation for the parsec package states that u argument is used to carry some user state through monadic computation. But the same functionality can be achieved by basing ParsecT monad transformer on State monad. So if my parser is not stateful, i don't need u altogether, but have to set it to () with parsec. What's rationale for adding non-optional state support to ParsecT ? 回答1: Because a parser of type ParsecT s () (State st) a behaves differently from a parser of type Parsec s st

Parsec vs Yacc/Bison/Antlr: Why and when to use Parsec?

前提是你 提交于 2019-11-28 03:20:00
I'm new to Haskell and Parsec. After reading Chapter 16 Using Parsec of Real World Haskell , a question appeared in my mind: Why and when is Parsec better than other parser generators like Yacc/Bison/Antlr? My understanding is that Parsec creates a nice DSL of writing parsers and Haskell makes it very easy and expressive. But parsing is such a standard/popular technology that deserves its own language, which outputs to multiple target languages. So when shall we use Parsec instead of, say, generating Haskell code from Bison/Antlr? This question might go a little beyond technology, and into the

Parsec.Expr repeated Prefix/Postfix operator not supported

 ̄綄美尐妖づ 提交于 2019-11-27 16:01:04
问题 The documentation for Parsec.Expr.buildExpressionParser says: Prefix and postfix operators of the same precedence can only occur once (i.e. --2 is not allowed if - is prefix negate). and indeed, this is biting me, since the language I am trying to parse allows arbitrary repetition of its prefix and postfix operators (think of a C expression like **a[1][2] ). So, why does Parsec make this restriction, and how can I work around it? I think I can move my prefix/postfix parsers down into the term

What are the benefits of applicative parsing over monadic parsing?

自闭症网瘾萝莉.ら 提交于 2019-11-27 09:15:33
问题 There seems to be a consensus that you should use Parsec as an applicative rather than a monad. What are the benefits of applicative parsing over monadic parsing? style performance abstraction Is monadic parsing out? 回答1: The main difference between monadic and applicative parsing is in how sequential composition is handled. In the case of an applicative parser, we use (<*>) , whereas with a monad we use (>>=) . (<*>) :: Parser (a -> b) -> Parser a -> Parser b (>>=) :: Parser a -> (a ->

Generate parser that runs a received parser on the output of another parser and monadically joins the results

一个人想着一个人 提交于 2019-11-27 08:07:20
问题 given the following type and function, meant to parse a field of a CSV field into a string: type Parser resultType = ParsecT String () Identity resultType cell :: Parser String I have implemented the following function: customCell :: String -> Parser res -> Parser res customCell typeName subparser = cell >>= either (const $ unexpected typeName) return . parse (subparser <* eof) "" Though I cannot stop thinking that I am not using the Monad concept as much as desired and that eventually there

What's the difference between Text.ParserCombinators.Parsec and Text.Parsec

好久不见. 提交于 2019-11-27 01:45:24
问题 Text Text.Parsec Text.Parsec.ByteString Text.Parsec.ByteString.Lazy Text.Parsec.Char Text.Parsec.Combinator Text.Parsec.Error Text.Parsec.Expr Text.Parsec.Language Text.Parsec.Perm Text.Parsec.Pos Text.Parsec.Prim Text.Parsec.String Text.Parsec.Token ParserCombinators Text.ParserCombinators.Parsec Text.ParserCombinators.Parsec.Char Text.ParserCombinators.Parsec.Combinator Text.ParserCombinators.Parsec.Error Text.ParserCombinators.Parsec.Expr Text.ParserCombinators.Parsec.Language Text