regexqq-0.6: A quasiquoter for PCRE regexes.

Portabilitynon-portable (GHC QuasiQuotes)



A quasiquoter for Text.Regex.PCRE regexes. This makes use of a new GHC extension known as QuasiQuotes. See the README for the temporary location of the docs for Language.Haskell.TH.Quote. See the EXAMPLES file for examples.

 ghci> [$rx|([aeiou]).*(er|ing|tion)([\.,\?]*)$|] "helloing.!?!?!"
 Just ["elloing.!?!?!","e","ing",".!?!?!"]



rx :: QuasiQuoterSource

 ghci> maybe [] tail $ [$rx|^([+-])?([0-9]+)\.([0-9]+)|] (show $ negate pi)

regexToExpQ :: String -> ExpQSource

Transform a string rep of a regex to an ExpQ. The resulting ExpQ, when spliced, results in a function of type String -> Maybe [String], where the input is the String to match on. The result is Nothing on error, and Just a list of results on success. Note: I'm packing/unpacking/... the ByteString unnecessarily for convenience in testing out the first go at this. This will be dealt with in the future.

regexToPatQ :: String -> PatQSource

Transform a string (presumably) containing a regex to a PatQ. NOTE: Given a regex, a pattern is constructed which matches a literal string containing the verbatim regex. It does this because I couldn't think of anything better for it to do off the cuff. This needs thought.