File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,11 @@ import Data.String
7
7
import Control.Monad.State.Class
8
8
import Control.Monad.Error.Class
9
9
10
+ import Data.Foldable
11
+ import Data.Monoid
12
+
10
13
import Text.Parsing.Parser
14
+ import Text.Parsing.Parser.Combinators
11
15
12
16
eof :: forall m . (Monad m ) => ParserT String m {}
13
17
eof = do
@@ -36,3 +40,14 @@ char = do
36
40
put (substring 1 (lengthS s) s)
37
41
return (substr 0 1 s)
38
42
43
+ satisfy :: forall m . (Monad m ) => (String -> Boolean ) -> ParserT String m String
44
+ satisfy f = do
45
+ p <- char
46
+ r <- if not $ f p then fail " Character did not satisfy prediate" else return p
47
+ return r
48
+
49
+ whiteSpace :: forall m . (Monad m ) => ParserT String m String
50
+ whiteSpace = do
51
+ list <- many $ string " \n " <|> string " \r " <|> string " " <|> string " \t "
52
+ return $ foldMap id list
53
+
You can’t perform that action at this time.
0 commit comments