diff --git a/ParsingIntroduction.lhs b/ParsingIntroduction.lhs index 650200d..173f75e 100644 --- a/ParsingIntroduction.lhs +++ b/ParsingIntroduction.lhs @@ -17,28 +17,13 @@ favourite editor, and use ghci to experiment. To download, use: git clone https://github.com/JakeWheat/intro_to_parsing.git ``` -TODO: experiment: create wrapper modules for all the interesting stuff -in parsec, which fixes the parser types to use -Text.Parsec.String.Parser. This should make things much simpler for -beginners, especially reading the code and dealing with error -messages. - -modules: -parse, ParseError from somewhere -Text.Parsec.Char -Text.Parsec.Combinator - > import Text.Parsec (ParseError) > import Text.Parsec.String (Parser) - > import Text.Parsec.String.Parsec (try, parse) - > import Text.Parsec.String.Char (anyChar, oneOf, char, digit > ,string, letter, satisfy) - > import Text.Parsec.String.Combinator (eof,manyTill, many1, choice > ,anyToken,chainl1, between) - > import Control.Applicative ((<$>), (<*>), (<$), (<*), (*>), (<|>), many) > import Control.Monad (void, ap) > import Data.Char (isLetter, isDigit) @@ -169,7 +154,8 @@ This can be used to quickly try out new ad hoc parsers. = Type signatures TODO: update with new wrapper types which mean all this nonsense can -be delayed to much later. +be delayed to much later. Instead, a quick note here about the +wrappers and how they help. I think you should always use type signatures with Parsec. Because the Parsec code is really generalized, without the type GHC will refuse to diff --git a/Text/Parsec/String/Expr.hs b/Text/Parsec/String/Expr.hs index 3ebc68b..a54bb18 100644 --- a/Text/Parsec/String/Expr.hs +++ b/Text/Parsec/String/Expr.hs @@ -14,6 +14,8 @@ Wrappers for the Text.Parsec.Expr module with simplified types. import Text.Parsec.String (Parser) import qualified Text.Parsec.Expr as E +-- not sure if this is neccessary, or a type alias would be good +-- enough data Operator a = Infix (Parser (a -> a -> a)) E.Assoc | Prefix (Parser (a -> a)) | Postfix (Parser (a -> a)) diff --git a/plan b/plan index 549f55b..d072bd1 100644 --- a/plan +++ b/plan @@ -16,12 +16,21 @@ review and remove explicit explanations where feasible, replace with more examples break up parsing introduction into several docs, it's huge +1. IntroductionToParsing + Text.Parsec.Char review +2. SimpleExpressionParser +3. Text.Parsec.Combinators + Control.Applicative review +4. Helper functions module + notes maybe have a sequence of docs for expression parsing, in the middle will be the simple sql value expression parser maybe split parsecextras file into three also? +value expressions: start with the basic one in the first tutorial then +have the one in the Expr tutorial then extend this with the simplified +sql parser set of operators then create a new parser with each new +ctor one at a time. This way can also do the naive thing first, then +talk about how to deal with the problems that come up. documents which need finishing off: