File tree Expand file tree Collapse file tree 4 files changed +28
-23
lines changed Expand file tree Collapse file tree 4 files changed +28
-23
lines changed Original file line number Diff line number Diff line change 30
30
"purescript-lists" : " ^1.0.0"
31
31
},
32
32
"devDependencies" : {
33
- "purescript-math" : " ^2.0.0" ,
34
- "purescript-quickcheck" : " ^1.0.0"
33
+ "purescript-math" : " ^2.0.0"
35
34
}
36
35
}
Original file line number Diff line number Diff line change @@ -36,37 +36,39 @@ The type of parsing errors.
36
36
37
37
##### Instances
38
38
``` purescript
39
- instance showParseError :: Show ParseError
40
- instance eqParseError :: Eq ParseError
39
+ Show ParseError
40
+ Eq ParseError
41
41
```
42
42
43
43
#### ` Parser `
44
44
45
45
``` purescript
46
46
data Parser a
47
- = Parser (forall r. PosString -> ( Pos -> ParseError -> r) -> (a -> PosString -> r) -> r )
47
+ = Parser (PosString -> Either { pos :: Pos, error :: ParseError } { result :: a, suffix :: PosString } )
48
48
```
49
49
50
50
A parser is represented as a function which takes a pair of
51
51
continuations for failure and success.
52
52
53
53
##### Instances
54
54
``` purescript
55
- instance functorParser :: Functor Parser
56
- instance applyParser :: Apply Parser
57
- instance applicativeParser :: Applicative Parser
58
- instance altParser :: Alt Parser
59
- instance plusParser :: Plus Parser
60
- instance alternativeParser :: Alternative Parser
61
- instance bindParser :: Bind Parser
62
- instance monadParser :: Monad Parser
63
- instance monadPlusParser :: MonadPlus Parser
55
+ Functor Parser
56
+ Apply Parser
57
+ Applicative Parser
58
+ Alt Parser
59
+ Plus Parser
60
+ Alternative Parser
61
+ Bind Parser
62
+ Monad Parser
63
+ MonadZero Parser
64
+ MonadPlus Parser
65
+ MonadRec Parser
64
66
```
65
67
66
68
#### ` unParser `
67
69
68
70
``` purescript
69
- unParser :: forall a r . Parser a -> PosString -> ( Pos -> ParseError -> r) -> (a -> PosString -> r) -> r
71
+ unParser :: forall a. Parser a -> PosString -> Either { pos :: Pos, error :: ParseError } { result :: a, suffix :: PosString }
70
72
```
71
73
72
74
Run a parser by providing success and failure continuations.
Original file line number Diff line number Diff line change @@ -26,16 +26,20 @@ many1 :: forall a. Parser a -> Parser (List a)
26
26
27
27
Match one or more times.
28
28
29
- #### ` (<?>) `
29
+ #### ` withError `
30
30
31
31
``` purescript
32
- (<?>) :: forall a. Parser a -> String -> Parser a
32
+ withError :: forall a. Parser a -> String -> Parser a
33
33
```
34
34
35
- _ left-associative / precedence -1_
36
-
37
35
Provide an error message in case of failure.
38
36
37
+ #### ` (<?>) `
38
+
39
+ ``` purescript
40
+ infixl 3 withError as <?>
41
+ ```
42
+
39
43
#### ` fix `
40
44
41
45
``` purescript
@@ -74,7 +78,7 @@ Attempt to parse a value.
74
78
optionMaybe :: forall a. Parser a -> Parser (Maybe a)
75
79
```
76
80
77
- Attempt to parse a value, returning ` Nothing ` in case of failure.
81
+ Attempt to parse a value, pureing ` Nothing ` in case of failure.
78
82
79
83
#### ` sepBy `
80
84
@@ -175,7 +179,7 @@ Parse one or more values separated by a right-associative operator.
175
179
#### ` choice `
176
180
177
181
``` purescript
178
- choice :: forall f a. ( Foldable f) => f (Parser a) -> Parser a
182
+ choice :: forall f a. Foldable f => f (Parser a) -> Parser a
179
183
```
180
184
181
185
Parse using any of a collection of parsers.
Original file line number Diff line number Diff line change @@ -69,15 +69,15 @@ Skip many whitespace characters.
69
69
#### ` oneOf `
70
70
71
71
``` purescript
72
- oneOf :: forall f. ( Foldable f) => f Char -> Parser Char
72
+ oneOf :: forall f. Foldable f => f Char -> Parser Char
73
73
```
74
74
75
75
Match one of the characters in the foldable structure.
76
76
77
77
#### ` noneOf `
78
78
79
79
``` purescript
80
- noneOf :: forall f. ( Foldable f) => f Char -> Parser Char
80
+ noneOf :: forall f. Foldable f => f Char -> Parser Char
81
81
```
82
82
83
83
Match any character not in the foldable structure.
You can’t perform that action at this time.
0 commit comments