aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/attoparser.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/attoparser.hs')
-rw-r--r--examples/attoparser.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/attoparser.hs b/examples/attoparser.hs
new file mode 100644
index 0000000..ddf770d
--- /dev/null
+++ b/examples/attoparser.hs
@@ -0,0 +1,21 @@
1import Pipes
2import Pipes.Text.IO (fromHandle)
3import Pipes.Attoparsec (parsed)
4import qualified System.IO as IO
5
6data Test = Test {
7 a :: Int,
8 b :: Int
9 } deriving (Show)
10
11testParser :: Parser Test
12testParser = do
13 a <- decimal
14 space
15 b <- decimal
16 endOfLine
17 return $ Test a b
18
19main = IO.withFile "./testfile" IO.ReadMode $ \handle -> runEffect $
20 for test_parser (lift . print)
21 where (parsed (testParser <* endOfLine) (fromHandle handle)) \ No newline at end of file