Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWheat committed Jan 1, 2014
1 parent 47085c4 commit 9068ef7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
18 changes: 2 additions & 16 deletions ParsingIntroduction.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Text/Parsec/String/Expr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 9 additions & 0 deletions plan
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 9068ef7

Please sign in to comment.