* Matthias Hörmann <[email protected]> [2012-05-31 10:40:31+0200]
> I noticed there are still some other problems in the code. In particular it
> doesn't work as intended in cases
> like this one:
>
> parseTest (do; r1 <- anyOf ["Hello", "Hallo", "Foo", "HallofFame"]; r2 <-
> string "fbla"; return (r1, r2)) "Hallofbla"
>
> where it should (according to my goal) return no parse error but instead
> accept "Hallo" and allow the string parser
> to consume the rejected suffix but I will try to fix that.
This looks more like a job for regular expressions.
E.g. using the regex-applicative package:
> let anyOf = foldr1 (<|>) . map string
> let re = (,) <$> anyOf ["Hello", "Hallo", "Foo", "HallofFame"] <*> string
"fbla"
> "Hallofbla" =~ re
Just ("Hallo","fbla")
Theoretically regular expressions also do the kind of optimization that
you achieve with a trie, but this particular engine doesn't. Nevertheless,
it may be a good base for your own engine.
--
Roman I. Cheplyaka :: http://ro-che.info/
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe