Skip to content

Commit 41cb79a

Browse files
committed
Add basic definition of Parser type
1 parent 5b9e017 commit 41cb79a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Control.Applicative
2+
import Data.Char
3+
4+
newtype Parser a = P (String -> [(a, String)])
5+
6+
parse :: Parser a -> String -> [(a, String)]
7+
parse (P p) inp = p inp
8+
9+
item :: Parser Char
10+
item = P $ \inp ->
11+
case inp of
12+
[] -> []
13+
(x:xs) -> [(x, xs)]

0 commit comments

Comments
 (0)