> data MyType
> = Foo
> | Baz
> | Err
> deriving Show
> parseMyType = (string "Foo" >> return Foo)
> <|> (string "Baz" >> return Baz)
> parseNoBaz = callCC $ \k -> do
> result <- parseMyType
> validateResult k result
> return result
> validateResult k Baz = k Err
> validateResult k _ = return ()
> manyNoBaz = parseNoBaz `sepBy` space
> test p s = flip runCont id (runPT p () "test" s)
Then, if I execute test manyNoBaz "Foo Foo Baz Foo" I get the result:
[Foo,Foo,Err,Foo]
This is a contrived example, but I think it's pretty neat.
1 comment:
Good reeading
Post a Comment