-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A quasi-quoter for typeful results of regex captures.
--
-- Provides a quasi-quoter for regular expressions which yields a tuple,
-- of appropriate arity and types, representing the results of the
-- captures. Allows the user to specify parsers for captures as inline
-- Haskell. Can also be used to provide typeful pattern matching in
-- function definitions and pattern matches. Also, it precompiles the
-- regular expressions into a PCRE compiled byte-array representation, at
-- compile time.
@package rex
@version 0.6
-- | This module provides support for accessing the compiled representation
-- of PCRE regular expressions. This byte array encodes a lookup-table
-- based representation for the regular expression, and can be safely
-- written out and read back by compatible PCRE versions.
module Text.Regex.PCRE.Precompile
-- | A synonym indicating which ByteStrings represent PCRE-format compiled
-- data.
type CompiledBytes = ByteString
-- | Compiles the given regular expression, and assuming nothing bad
-- happens, yields the bytestring filled with PCRE's compiled
-- representation.
precompile :: ByteString -> [PCREOption] -> IO (Maybe CompiledBytes)
-- | Takes a compiled regular expression, and if successful, yields the
-- compiled representation.
regexToTable :: Regex -> IO (Maybe CompiledBytes)
-- | Creates a regular expression from the compiled representation.
regexFromTable :: CompiledBytes -> IO Regex
-- | This module provides a template Haskell quasiquoter for regular
-- expressions, which provides the following features:
--
-- 1) Compile-time checking that the regular expression is valid.
--
-- 2) Arity of resulting tuple based on the number of selected capture
-- patterns in the regular expression.
--
-- 3) Allows for the inline interpolation of mapping functions :: String
-- -> a.
--
-- 4) Precompiles the regular expression at compile time, by calling into
-- the PCRE library and storing a ByteString literal
-- representation of its state.
--
-- 5) Compile-time configurable to use different PCRE options, turn off
-- precompilation, use ByteStrings, or set a default mapping
-- expression.
--
-- Inspired by Matt Morrow's regexqq package:
-- http://hackage.haskell.org/package/regexqq/docs/Text-Regex-PCRE-QQ.html.
--
-- And some code from Erik Charlebois's interpolatedstring-qq package:
-- http://hackage.haskell.org/package/interpolatedstring-qq/.
module Text.Regex.PCRE.Rex
-- | Rex quasiquoter which takes String as input, and uses
-- defaultRexConf for its configuration. Can be used in
-- expressions and patterns.
rex :: QuasiQuoter
-- | Rex quasiquoter which takes ByteString as input, and otherwise
-- uses defaultRexConf for its configuration. Can be used in
-- expressions and patterns.
brex :: QuasiQuoter
-- | A configureable regular-expression QuasiQuoter. Takes the options to
-- pass to the PCRE engine, along with Bools to flag
-- ByteString usage and non-compilation respecively. The provided
-- String indicates which mapping function to use, when one is
-- omitted - "(?{} ...)".
rexWithConf :: RexConf -> QuasiQuoter
data RexConf
RexConf :: Bool -> Bool -> (String -> String) -> (String -> String) -> Exp -> [PCREOption] -> [PCREExecOption] -> RexConf
-- | When True, the input type is a ByteString, otherwise, it's a
-- String.
[rexByteString] :: RexConf -> Bool
-- | When True, the regex is precompiled.
[rexCompiled] :: RexConf -> Bool
-- | Preprocess the string used in expression antiquotes.
-- defaultRexConf just passes through the string unaltered, unless
-- it just consists of whitespace. When it's all whitespace,
-- "rexView" is used.
[rexPreprocessExp] :: RexConf -> String -> String
-- | Preprocess the string used in pattern antiquotes.
-- defaultRexConf adds parenthesis around the string, so that view
-- patterns will parse without requiring parenthesis around them.
[rexPreprocessPat] :: RexConf -> String -> String
-- | When a pattern match doesn't have a view pattern, this expression is
-- used to preprocess it before matching. When defaultRexConf is
-- used, perhaps via rex or brex, a reference to
-- rexView is used.
--
-- The rexView exported by this module is id, so by default
-- no preprocessing is done before
[rexViewExp] :: RexConf -> Exp
-- | Options used when compiling PCRE regular expressions.
[rexPCREOpts] :: RexConf -> [PCREOption]
-- | Options used when executing PCRE regular expressions.
[rexPCREExecOpts] :: RexConf -> [PCREExecOption]
-- | Default rex configuration, which specifies that the regexes operate on
-- strings, don't post-process the matched patterns, and use
-- extended. This setting causes whitespace to be non-semantic,
-- and ignores # comments.
defaultRexConf :: RexConf
-- | This is a QuasiQuoter transformer, which allows for a
-- whitespace- sensitive quasi-quoter to be broken over multiple lines.
-- The default rex and brex functions do not need this as
-- they are already whitespace insensitive. However, if you create your
-- own configuration, which omits the extended parameter, then
-- this could be useful. The leading space of each line is ignored, and
-- all newlines removed.
makeQuasiMultiline :: QuasiQuoter -> QuasiQuoter
-- | Converts Left to ParseFailed noLoc,
-- and a Right to ParseOk.
eitherToParseResult :: Either String a -> ParseResult a
-- | Parse a Haskell expression into a Template Haskell Exp.
parseExp :: String -> ParseResult Exp
-- | Parse a Haskell pattern match into a Template Haskell Pat.
parsePat :: String -> ParseResult Pat
-- | Parse mode used by parseExp and parsePat.
rexParseMode :: ParseMode
-- | A default view function used when expression antiquotes are empty, or
-- when pattern antiquotes omit a view pattern. See the documentation for
-- rexPreprocessPat and rexPreprocessExp for more details.
--
-- You can locally shadow this rexView with your own version, if
-- you wish. One good option is readMay from the safe package:
-- http://hackage.haskell.org/package/safe/docs/Safe.html#v:readMay.
--
-- The type of this identity rexView is fully polymorphic so that it can
-- be used with either String or ByteString.
rexView :: a -> a