Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Text.Regex.Pcre2.Unsafe
Description
These items are unsafe for one reason or another, and are sequestered here to require the user to do an extra import to get them.
Chief among
them is the callout interface: these options and associated datatypes may be
used to register effectful callbacks, sometimes referred to as callouts in
the PCRE2 API, for regex compilation, matching, and substitution. We include
them here for completeness and use them to implement unit tests for this
library; for ordinary use, however, seek other means to accomplish whatever
is needed (such as accreting effects with optics), since they carry all the
problems of unsafePerformIO
. See
the C API docs
for more information.
Synopsis
- data Option
- data CalloutInfo = CalloutInfo {}
- data CalloutIndex
- data CalloutResult
- data SubCalloutInfo = SubCalloutInfo {}
- data SubCalloutResult
Options
A Monoid
representing nearly every facility PCRE2 presents for tweaking
the behavior of regex compilation and execution.
All library functions that take options have the suffix Opt
in their names;
for each of them, there's also a non-Opt
convenience function that simply
has the (unexported) mempty
option. For many uses, options won't be
needed.
Some options can be enabled by special character sequences in the pattern as
an alternative to specifying them as an Option
. See Caseless
for
example.
Most options are exported in Text.Regex.Pcre2. The callout interface is found in Text.Regex.Pcre2.Unsafe.
Documentation is scant here. For more complete, accurate information, including discussions of corner cases arising from specific combinations of options and pattern items, please see the C API documentation.
Constructors
BadEscapeIsLiteral | Do not throw an error for unrecognized or malformed escapes. "This is a dangerous option." |
UnsafeCompileRecGuard (Int -> IO Bool) | Run the given guard on every
new descent into a level of parentheses, passing the current depth as
argument. Returning NOTE: Currently (PCRE2 version 10.39) patterns seem to be compiled in two passes, both times triggering the recursion guard. Also, it is triggered at the beginning of the pattern, passing 0. None of this is documented; expect the unexpected in the presence of side effects! |
UnsafeCallout (CalloutInfo -> IO CalloutResult) | Run the given callout at every callout point (see the docs for more info). Multiples of this option before the rightmost are ignored. |
AutoCallout | Run callout for every pattern item. Only relevant if a callout is set. |
UnsafeSubCallout (SubCalloutInfo -> IO SubCalloutResult) | Run the
given callout on every substitution. This is at most once unless
|
Types
data CalloutInfo Source #
Input for user-defined callouts.
Constructors
CalloutInfo | |
Fields
|
Instances
Show CalloutInfo Source # | |
Defined in Text.Regex.Pcre2.Internal Methods showsPrec :: Int -> CalloutInfo -> ShowS # show :: CalloutInfo -> String # showList :: [CalloutInfo] -> ShowS # | |
Eq CalloutInfo Source # | |
Defined in Text.Regex.Pcre2.Internal |
data CalloutIndex Source #
What caused the callout.
Constructors
CalloutNumber Int | Numerical callout. |
CalloutName Text | String callout. |
CalloutAuto Int Int | The item located at this half-open range of
offsets within the pattern. See |
Instances
Show CalloutIndex Source # | |
Defined in Text.Regex.Pcre2.Internal Methods showsPrec :: Int -> CalloutIndex -> ShowS # show :: CalloutIndex -> String # showList :: [CalloutIndex] -> ShowS # | |
Eq CalloutIndex Source # | |
Defined in Text.Regex.Pcre2.Internal |
data CalloutResult Source #
Callout functions return one of these values, which dictates what happens next in the match.
Constructors
CalloutProceed | Keep going. |
CalloutNoMatchHere | Fail the current capture, but not the whole match. For example, backtracking may occur. |
CalloutNoMatch | Fail the whole match. |
Instances
Show CalloutResult Source # | |
Defined in Text.Regex.Pcre2.Internal Methods showsPrec :: Int -> CalloutResult -> ShowS # show :: CalloutResult -> String # showList :: [CalloutResult] -> ShowS # | |
Eq CalloutResult Source # | |
Defined in Text.Regex.Pcre2.Internal Methods (==) :: CalloutResult -> CalloutResult -> Bool # (/=) :: CalloutResult -> CalloutResult -> Bool # |
data SubCalloutInfo Source #
Input for user-defined substitution callouts.
Constructors
SubCalloutInfo | |
Fields
|
Instances
Show SubCalloutInfo Source # | |
Defined in Text.Regex.Pcre2.Internal Methods showsPrec :: Int -> SubCalloutInfo -> ShowS # show :: SubCalloutInfo -> String # showList :: [SubCalloutInfo] -> ShowS # | |
Eq SubCalloutInfo Source # | |
Defined in Text.Regex.Pcre2.Internal Methods (==) :: SubCalloutInfo -> SubCalloutInfo -> Bool # (/=) :: SubCalloutInfo -> SubCalloutInfo -> Bool # |
data SubCalloutResult Source #
Substitution callout functions return one of these values, which dictates what happens next in the substitution.
Constructors
SubCalloutAccept | Succeed, and keep going if in global mode. |
SubCalloutSkip | Do not perform this substitution, but keep going if in global mode. |
SubCalloutAbort | Do not perform this or any subsequent substitutions. |
Instances
Show SubCalloutResult Source # | |
Defined in Text.Regex.Pcre2.Internal Methods showsPrec :: Int -> SubCalloutResult -> ShowS # show :: SubCalloutResult -> String # showList :: [SubCalloutResult] -> ShowS # | |
Eq SubCalloutResult Source # | |
Defined in Text.Regex.Pcre2.Internal Methods (==) :: SubCalloutResult -> SubCalloutResult -> Bool # (/=) :: SubCalloutResult -> SubCalloutResult -> Bool # |