{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 800
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
#else
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
#endif
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Text.RE.ZeInternals.PCRE
(
RE
, regexType
, reOptions
, reSource
, reCaptureNames
, reRegex
, IsOption(..)
, REOptions
, defaultREOptions
, noPreludeREOptions
, unpackSimpleREOptions
, compileRegex
, compileRegexWith
, compileRegexWithOptions
, compileSearchReplace
, compileSearchReplaceWith
, compileSearchReplaceWithOptions
, escape
, escapeWith
, escapeWithOptions
, escapeREString
, prelude
, preludeEnv
, preludeTestsFailing
, preludeTable
, preludeSummary
, preludeSources
, preludeSource
, re
, reMS
, reMI
, reBS
, reBI
, reMultilineSensitive
, reMultilineInsensitive
, reBlockSensitive
, reBlockInsensitive
, re_
, cp
) where
import Control.Monad.Fail
import Data.Bits
import Data.Functor.Identity
import Language.Haskell.TH
import Language.Haskell.TH.Quote
import Prelude.Compat hiding (fail)
import Text.RE.REOptions
import Text.RE.Replace
import Text.RE.TestBench
import Text.RE.Tools
import Text.RE.ZeInternals
import Text.RE.ZeInternals.Types.Poss
import Text.Regex.PCRE
data RE =
RE
{ RE -> REOptions
_re_options :: !REOptions
, RE -> String
_re_source :: !String
, RE -> CaptureNames
_re_cnames :: !CaptureNames
, RE -> Regex
_re_regex :: !Regex
}
regexType :: RegexType
regexType :: RegexType
regexType =
TestBenchMatcher -> RegexType
mkPCRE (TestBenchMatcher -> RegexType) -> TestBenchMatcher -> RegexType
forall a b. (a -> b) -> a -> b
$ \String
txt MacroEnv
env MacroDescriptor
md -> String
txt String -> String -> Matches String
forall source source1 target.
(RegexMaker Regex CompOption ExecOption source,
RegexContext Regex source1 target) =>
source1 -> source -> target
=~ RegexType -> WithCaptures -> MacroEnv -> MacroDescriptor -> String
mdRegexSource RegexType
regexType WithCaptures
ExclCaptures MacroEnv
env MacroDescriptor
md
reOptions :: RE -> REOptions
reOptions :: RE -> REOptions
reOptions = RE -> REOptions
_re_options
reSource :: RE -> String
reSource :: RE -> String
reSource = RE -> String
_re_source
reCaptureNames :: RE -> CaptureNames
reCaptureNames :: RE -> CaptureNames
reCaptureNames = RE -> CaptureNames
_re_cnames
reRegex :: RE -> Regex
reRegex :: RE -> Regex
reRegex = RE -> Regex
_re_regex
class IsOption o where
makeREOptions :: o -> REOptions
type REOptions = REOptions_ RE CompOption ExecOption
instance IsOption SimpleREOptions where
makeREOptions :: SimpleREOptions -> REOptions
makeREOptions = SimpleREOptions -> REOptions
unpackSimpleREOptions
instance IsOption (Macros RE) where
makeREOptions :: Macros RE -> REOptions
makeREOptions Macros RE
ms = Macros RE -> CompOption -> ExecOption -> REOptions
forall r c e. Macros r -> c -> e -> REOptions_ r c e
REOptions Macros RE
ms CompOption
def_comp_option ExecOption
def_exec_option
instance IsOption CompOption where
makeREOptions :: CompOption -> REOptions
makeREOptions CompOption
co = Macros RE -> CompOption -> ExecOption -> REOptions
forall r c e. Macros r -> c -> e -> REOptions_ r c e
REOptions Macros RE
prelude CompOption
co ExecOption
def_exec_option
instance IsOption ExecOption where
makeREOptions :: ExecOption -> REOptions
makeREOptions ExecOption
eo = Macros RE -> CompOption -> ExecOption -> REOptions
forall r c e. Macros r -> c -> e -> REOptions_ r c e
REOptions Macros RE
prelude CompOption
def_comp_option ExecOption
eo
instance IsOption REOptions where
makeREOptions :: REOptions -> REOptions
makeREOptions = REOptions -> REOptions
forall a. a -> a
id
instance IsOption () where
makeREOptions :: () -> REOptions
makeREOptions ()
_ = SimpleREOptions -> REOptions
unpackSimpleREOptions SimpleREOptions
forall a. Bounded a => a
minBound
defaultREOptions :: REOptions
defaultREOptions :: REOptions
defaultREOptions = SimpleREOptions -> REOptions
forall o. IsOption o => o -> REOptions
makeREOptions (SimpleREOptions
forall a. Bounded a => a
minBound::SimpleREOptions)
noPreludeREOptions :: REOptions
noPreludeREOptions :: REOptions
noPreludeREOptions = REOptions
defaultREOptions { optionsMacs :: Macros RE
optionsMacs = Macros RE
forall r. Macros r
emptyMacros }
unpackSimpleREOptions :: SimpleREOptions -> REOptions
unpackSimpleREOptions :: SimpleREOptions -> REOptions
unpackSimpleREOptions SimpleREOptions
sro =
REOptions :: forall r c e. Macros r -> c -> e -> REOptions_ r c e
REOptions
{ optionsMacs :: Macros RE
optionsMacs = Macros RE
prelude
, optionsComp :: CompOption
optionsComp = CompOption
comp
, optionsExec :: ExecOption
optionsExec = ExecOption
forall regex compOpt execOpt.
RegexOptions regex compOpt execOpt =>
execOpt
defaultExecOpt
}
where
comp :: CompOption
comp =
Bool -> CompOption -> CompOption -> CompOption
forall a. Bits a => Bool -> a -> a -> a
wiggle Bool
ml CompOption
compMultiline (CompOption -> CompOption) -> CompOption -> CompOption
forall a b. (a -> b) -> a -> b
$
Bool -> CompOption -> CompOption -> CompOption
forall a. Bits a => Bool -> a -> a -> a
wiggle Bool
ci CompOption
compCaseless
CompOption
forall regex compOpt execOpt.
RegexOptions regex compOpt execOpt =>
compOpt
defaultCompOpt
wiggle :: Bool -> a -> a -> a
wiggle Bool
True a
m a
v = a
v a -> a -> a
forall a. Bits a => a -> a -> a
.|. a
m
wiggle Bool
False a
m a
v = a
v a -> a -> a
forall a. Bits a => a -> a -> a
.&. a -> a
forall a. Bits a => a -> a
complement a
m
(Bool
ml,Bool
ci) = case SimpleREOptions
sro of
SimpleREOptions
MultilineSensitive -> (,) Bool
True Bool
False
SimpleREOptions
MultilineInsensitive -> (,) Bool
True Bool
True
SimpleREOptions
BlockSensitive -> (,) Bool
False Bool
False
SimpleREOptions
BlockInsensitive -> (,) Bool
False Bool
True
compileRegex :: (Functor m,Monad m, MonadFail m) => String -> m RE
compileRegex :: String -> m RE
compileRegex = SimpleREOptions -> String -> m RE
forall (m :: * -> *).
(Functor m, Monad m, MonadFail m) =>
SimpleREOptions -> String -> m RE
compileRegexWith SimpleREOptions
forall a. Bounded a => a
minBound
compileRegexWith :: (Functor m,Monad m, MonadFail m) => SimpleREOptions -> String -> m RE
compileRegexWith :: SimpleREOptions -> String -> m RE
compileRegexWith = SimpleREOptions -> String -> m RE
forall o (m :: * -> *).
(IsOption o, Functor m, Monad m, MonadFail m) =>
o -> String -> m RE
compileRegexWithOptions
compileRegexWithOptions :: (IsOption o, Functor m, Monad m, MonadFail m)
=> o
-> String
-> m RE
compileRegexWithOptions :: o -> String -> m RE
compileRegexWithOptions = REOptions -> String -> m RE
forall (m :: * -> *).
(Functor m, Monad m, MonadFail m) =>
REOptions -> String -> m RE
compileRegex_ (REOptions -> String -> m RE)
-> (o -> REOptions) -> o -> String -> m RE
forall b c a. (b -> c) -> (a -> b) -> a -> c
. o -> REOptions
forall o. IsOption o => o -> REOptions
makeREOptions
compileSearchReplace :: (Monad m,MonadFail m,Functor m,IsRegex RE s)
=> String
-> String
-> m (SearchReplace RE s)
compileSearchReplace :: String -> String -> m (SearchReplace RE s)
compileSearchReplace = SimpleREOptions -> String -> String -> m (SearchReplace RE s)
forall (m :: * -> *) s.
(Monad m, MonadFail m, Functor m, IsRegex RE s) =>
SimpleREOptions -> String -> String -> m (SearchReplace RE s)
compileSearchReplaceWith SimpleREOptions
forall a. Bounded a => a
minBound
compileSearchReplaceWith :: (Monad m,MonadFail m,Functor m,IsRegex RE s)
=> SimpleREOptions
-> String
-> String
-> m (SearchReplace RE s)
compileSearchReplaceWith :: SimpleREOptions -> String -> String -> m (SearchReplace RE s)
compileSearchReplaceWith SimpleREOptions
sro = (String -> s)
-> (String -> Either String RE)
-> String
-> String
-> m (SearchReplace RE s)
forall (m :: * -> *) s re.
(Monad m, MonadFail m, Functor m) =>
(String -> s)
-> (String -> Either String re)
-> String
-> String
-> m (SearchReplace re s)
compileSearchAndReplace_ String -> s
forall a. Replace a => String -> a
packR ((String -> Either String RE)
-> String -> String -> m (SearchReplace RE s))
-> (String -> Either String RE)
-> String
-> String
-> m (SearchReplace RE s)
forall a b. (a -> b) -> a -> b
$ Poss RE -> Either String RE
forall a. Poss a -> Either String a
poss2either (Poss RE -> Either String RE)
-> (String -> Poss RE) -> String -> Either String RE
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SimpleREOptions -> String -> Poss RE
forall (m :: * -> *).
(Functor m, Monad m, MonadFail m) =>
SimpleREOptions -> String -> m RE
compileRegexWith SimpleREOptions
sro
compileSearchReplaceWithOptions :: (Monad m,MonadFail m,Functor m,IsRegex RE s)
=> REOptions
-> String
-> String
-> m (SearchReplace RE s)
compileSearchReplaceWithOptions :: REOptions -> String -> String -> m (SearchReplace RE s)
compileSearchReplaceWithOptions REOptions
os = (String -> s)
-> (String -> Either String RE)
-> String
-> String
-> m (SearchReplace RE s)
forall (m :: * -> *) s re.
(Monad m, MonadFail m, Functor m) =>
(String -> s)
-> (String -> Either String re)
-> String
-> String
-> m (SearchReplace re s)
compileSearchAndReplace_ String -> s
forall a. Replace a => String -> a
packR ((String -> Either String RE)
-> String -> String -> m (SearchReplace RE s))
-> (String -> Either String RE)
-> String
-> String
-> m (SearchReplace RE s)
forall a b. (a -> b) -> a -> b
$ Poss RE -> Either String RE
forall a. Poss a -> Either String a
poss2either (Poss RE -> Either String RE)
-> (String -> Poss RE) -> String -> Either String RE
forall b c a. (b -> c) -> (a -> b) -> a -> c
. REOptions -> String -> Poss RE
forall o (m :: * -> *).
(IsOption o, Functor m, Monad m, MonadFail m) =>
o -> String -> m RE
compileRegexWithOptions REOptions
os
escape :: (Functor m,Monad m, MonadFail m)
=> (String->String)
-> String
-> m RE
escape :: (String -> String) -> String -> m RE
escape = SimpleREOptions -> (String -> String) -> String -> m RE
forall (m :: * -> *).
(Functor m, Monad m, MonadFail m) =>
SimpleREOptions -> (String -> String) -> String -> m RE
escapeWith SimpleREOptions
forall a. Bounded a => a
minBound
escapeWith :: (Functor m,Monad m, MonadFail m)
=> SimpleREOptions
-> (String->String)
-> String
-> m RE
escapeWith :: SimpleREOptions -> (String -> String) -> String -> m RE
escapeWith = SimpleREOptions -> (String -> String) -> String -> m RE
forall o (m :: * -> *).
(IsOption o, Functor m, Monad m, MonadFail m) =>
o -> (String -> String) -> String -> m RE
escapeWithOptions
escapeWithOptions :: ( IsOption o, Functor m, Monad m, MonadFail m)
=> o
-> (String->String)
-> String
-> m RE
escapeWithOptions :: o -> (String -> String) -> String -> m RE
escapeWithOptions o
o String -> String
f = o -> String -> m RE
forall o (m :: * -> *).
(IsOption o, Functor m, Monad m, MonadFail m) =>
o -> String -> m RE
compileRegexWithOptions o
o (String -> m RE) -> (String -> String) -> String -> m RE
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
f (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
escapeREString
prelude :: Macros RE
prelude :: Macros RE
prelude = Identity (Macros RE) -> Macros RE
forall a. Identity a -> a
runIdentity (Identity (Macros RE) -> Macros RE)
-> Identity (Macros RE) -> Macros RE
forall a b. (a -> b) -> a -> b
$ (String -> Identity RE)
-> RegexType -> WithCaptures -> Identity (Macros RE)
forall (m :: * -> *) r.
(Monad m, Functor m) =>
(String -> m r) -> RegexType -> WithCaptures -> m (Macros r)
preludeMacros String -> Identity RE
mk RegexType
regexType WithCaptures
ExclCaptures
where
mk :: String -> Identity RE
mk = RE -> Identity RE
forall a. a -> Identity a
Identity (RE -> Identity RE) -> (String -> RE) -> String -> Identity RE
forall b c a. (b -> c) -> (a -> b) -> a -> c
. REOptions -> String -> RE
unsafeCompileRegex_ REOptions
noPreludeREOptions
preludeEnv :: MacroEnv
preludeEnv :: MacroEnv
preludeEnv = RegexType -> MacroEnv
preludeMacroEnv RegexType
regexType
preludeTestsFailing :: [MacroID]
preludeTestsFailing :: [MacroID]
preludeTestsFailing = MacroEnv -> [MacroID]
badMacros MacroEnv
preludeEnv
preludeTable :: String
preludeTable :: String
preludeTable = RegexType -> String
preludeMacroTable RegexType
regexType
preludeSummary :: PreludeMacro -> String
preludeSummary :: PreludeMacro -> String
preludeSummary = RegexType -> PreludeMacro -> String
preludeMacroSummary RegexType
regexType
preludeSources :: String
preludeSources :: String
preludeSources = RegexType -> String
preludeMacroSources RegexType
regexType
preludeSource :: PreludeMacro -> String
preludeSource :: PreludeMacro -> String
preludeSource = RegexType -> PreludeMacro -> String
preludeMacroSource RegexType
regexType
re :: QuasiQuoter
re :: QuasiQuoter
re = Maybe SimpleREOptions -> QuasiQuoter
re' (Maybe SimpleREOptions -> QuasiQuoter)
-> Maybe SimpleREOptions -> QuasiQuoter
forall a b. (a -> b) -> a -> b
$ SimpleREOptions -> Maybe SimpleREOptions
forall a. a -> Maybe a
Just SimpleREOptions
forall a. Bounded a => a
minBound
reMultilineSensitive :: QuasiQuoter
reMultilineSensitive :: QuasiQuoter
reMultilineSensitive = Maybe SimpleREOptions -> QuasiQuoter
re' (Maybe SimpleREOptions -> QuasiQuoter)
-> Maybe SimpleREOptions -> QuasiQuoter
forall a b. (a -> b) -> a -> b
$ SimpleREOptions -> Maybe SimpleREOptions
forall a. a -> Maybe a
Just SimpleREOptions
MultilineSensitive
reMultilineInsensitive :: QuasiQuoter
reMultilineInsensitive :: QuasiQuoter
reMultilineInsensitive = Maybe SimpleREOptions -> QuasiQuoter
re' (Maybe SimpleREOptions -> QuasiQuoter)
-> Maybe SimpleREOptions -> QuasiQuoter
forall a b. (a -> b) -> a -> b
$ SimpleREOptions -> Maybe SimpleREOptions
forall a. a -> Maybe a
Just SimpleREOptions
MultilineInsensitive
reBlockSensitive :: QuasiQuoter
reBlockSensitive :: QuasiQuoter
reBlockSensitive = Maybe SimpleREOptions -> QuasiQuoter
re' (Maybe SimpleREOptions -> QuasiQuoter)
-> Maybe SimpleREOptions -> QuasiQuoter
forall a b. (a -> b) -> a -> b
$ SimpleREOptions -> Maybe SimpleREOptions
forall a. a -> Maybe a
Just SimpleREOptions
BlockSensitive
reBlockInsensitive :: QuasiQuoter
reBlockInsensitive :: QuasiQuoter
reBlockInsensitive = Maybe SimpleREOptions -> QuasiQuoter
re' (Maybe SimpleREOptions -> QuasiQuoter)
-> Maybe SimpleREOptions -> QuasiQuoter
forall a b. (a -> b) -> a -> b
$ SimpleREOptions -> Maybe SimpleREOptions
forall a. a -> Maybe a
Just SimpleREOptions
BlockInsensitive
reMS :: QuasiQuoter
reMS :: QuasiQuoter
reMS = QuasiQuoter
reMultilineSensitive
reMI :: QuasiQuoter
reMI :: QuasiQuoter
reMI = QuasiQuoter
reMultilineInsensitive
reBS :: QuasiQuoter
reBS :: QuasiQuoter
reBS = QuasiQuoter
reBlockSensitive
reBI :: QuasiQuoter
reBI :: QuasiQuoter
reBI = QuasiQuoter
reBlockInsensitive
re_ :: QuasiQuoter
re_ :: QuasiQuoter
re_ = Maybe SimpleREOptions -> QuasiQuoter
re' Maybe SimpleREOptions
forall a. Maybe a
Nothing
re' :: Maybe SimpleREOptions -> QuasiQuoter
re' :: Maybe SimpleREOptions -> QuasiQuoter
re' Maybe SimpleREOptions
mb = case Maybe SimpleREOptions
mb of
Maybe SimpleREOptions
Nothing ->
(String -> QuasiQuoter
qq0 String
"re'")
{ quoteExp :: String -> Q Exp
quoteExp = SimpleREOptions -> (String -> Q Exp) -> String -> Q Exp
parse SimpleREOptions
forall a. Bounded a => a
minBound (\String
rs->[|flip unsafeCompileRegex rs|])
}
Just SimpleREOptions
sro ->
(String -> QuasiQuoter
qq0 String
"re'")
{ quoteExp :: String -> Q Exp
quoteExp = SimpleREOptions -> (String -> Q Exp) -> String -> Q Exp
parse SimpleREOptions
sro (\String
rs->[|unsafeCompileRegexSimple sro rs|])
}
where
parse :: SimpleREOptions -> (String->Q Exp) -> String -> Q Exp
parse :: SimpleREOptions -> (String -> Q Exp) -> String -> Q Exp
parse SimpleREOptions
sro String -> Q Exp
mk String
rs = (String -> Q Exp) -> (RE -> Q Exp) -> Poss RE -> Q Exp
forall b a. (String -> b) -> (a -> b) -> Poss a -> b
poss String -> Q Exp
forall a. HasCallStack => String -> a
error (\RE
_->String -> Q Exp
mk String
rs) (Poss RE -> Q Exp) -> Poss RE -> Q Exp
forall a b. (a -> b) -> a -> b
$ REOptions -> String -> Poss RE
forall (m :: * -> *).
(Functor m, Monad m, MonadFail m) =>
REOptions -> String -> m RE
compileRegex_ REOptions
os String
rs
where
os :: REOptions
os = SimpleREOptions -> REOptions
unpackSimpleREOptions SimpleREOptions
sro
unsafeCompileRegexSimple :: SimpleREOptions -> String -> RE
unsafeCompileRegexSimple :: SimpleREOptions -> String -> RE
unsafeCompileRegexSimple SimpleREOptions
sro String
re_s = REOptions -> String -> RE
forall o. IsOption o => o -> String -> RE
unsafeCompileRegex REOptions
os String
re_s
where
os :: REOptions
os = SimpleREOptions -> REOptions
unpackSimpleREOptions SimpleREOptions
sro
unsafeCompileRegex :: IsOption o
=> o
-> String
-> RE
unsafeCompileRegex :: o -> String -> RE
unsafeCompileRegex = REOptions -> String -> RE
unsafeCompileRegex_ (REOptions -> String -> RE)
-> (o -> REOptions) -> o -> String -> RE
forall b c a. (b -> c) -> (a -> b) -> a -> c
. o -> REOptions
forall o. IsOption o => o -> REOptions
makeREOptions
unsafeCompileRegex_ :: REOptions -> String -> RE
unsafeCompileRegex_ :: REOptions -> String -> RE
unsafeCompileRegex_ REOptions
os = (String -> RE) -> (RE -> RE) -> Poss RE -> RE
forall b a. (String -> b) -> (a -> b) -> Poss a -> b
poss String -> RE
forall c. String -> c
oops RE -> RE
forall a. a -> a
id (Poss RE -> RE) -> (String -> Poss RE) -> String -> RE
forall b c a. (b -> c) -> (a -> b) -> a -> c
. REOptions -> String -> Poss RE
forall o (m :: * -> *).
(IsOption o, Functor m, Monad m, MonadFail m) =>
o -> String -> m RE
compileRegexWithOptions REOptions
os
where
oops :: String -> c
oops = String -> c
forall a. HasCallStack => String -> a
error (String -> c) -> (String -> String) -> String -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
"unsafeCompileRegex: " String -> String -> String
forall a. [a] -> [a] -> [a]
++)
compileRegex' :: (Functor m,Monad m,MonadFail m)
=> REOptions
-> String
-> m (CaptureNames,Regex)
compileRegex' :: REOptions -> String -> m (CaptureNames, Regex)
compileRegex' REOptions{CompOption
ExecOption
Macros RE
optionsExec :: ExecOption
optionsComp :: CompOption
optionsMacs :: Macros RE
optionsExec :: forall r c e. REOptions_ r c e -> e
optionsComp :: forall r c e. REOptions_ r c e -> c
optionsMacs :: forall r c e. REOptions_ r c e -> Macros r
..} String
s0 = do
((Int
_,CaptureNames
cnms),String
s2) <- (String -> m ((Int, CaptureNames), String))
-> (((Int, CaptureNames), String)
-> m ((Int, CaptureNames), String))
-> Either String ((Int, CaptureNames), String)
-> m ((Int, CaptureNames), String)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> m ((Int, CaptureNames), String)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail ((Int, CaptureNames), String) -> m ((Int, CaptureNames), String)
forall (m :: * -> *) a. Monad m => a -> m a
return (Either String ((Int, CaptureNames), String)
-> m ((Int, CaptureNames), String))
-> Either String ((Int, CaptureNames), String)
-> m ((Int, CaptureNames), String)
forall a b. (a -> b) -> a -> b
$ String -> Either String ((Int, CaptureNames), String)
extractNamedCaptures String
s1
(,) CaptureNames
cnms (Regex -> (CaptureNames, Regex))
-> m Regex -> m (CaptureNames, Regex)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CompOption -> ExecOption -> String -> m Regex
forall regex compOpt execOpt source (m :: * -> *).
(RegexMaker regex compOpt execOpt source, MonadFail m) =>
compOpt -> execOpt -> source -> m regex
makeRegexOptsM CompOption
optionsComp ExecOption
optionsExec String
s2
where
s1 :: String
s1 = (RE -> String) -> Macros RE -> String -> String
forall r. (r -> String) -> Macros r -> String -> String
expandMacros RE -> String
reSource Macros RE
optionsMacs String
s0
compileRegex_ :: ( Functor m , Monad m, MonadFail m )
=> REOptions
-> String
-> m RE
compileRegex_ :: REOptions -> String -> m RE
compileRegex_ REOptions
os String
re_s = (CaptureNames -> Regex -> RE) -> (CaptureNames, Regex) -> RE
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry CaptureNames -> Regex -> RE
mk ((CaptureNames, Regex) -> RE) -> m (CaptureNames, Regex) -> m RE
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> REOptions -> String -> m (CaptureNames, Regex)
forall (m :: * -> *).
(Functor m, Monad m, MonadFail m) =>
REOptions -> String -> m (CaptureNames, Regex)
compileRegex' REOptions
os String
re_s
where
mk :: CaptureNames -> Regex -> RE
mk CaptureNames
cnms Regex
rex =
RE :: REOptions -> String -> CaptureNames -> Regex -> RE
RE
{ _re_options :: REOptions
_re_options = REOptions
os
, _re_source :: String
_re_source = String
re_s
, _re_cnames :: CaptureNames
_re_cnames = CaptureNames
cnms
, _re_regex :: Regex
_re_regex = Regex
rex
}
def_comp_option :: CompOption
def_comp_option :: CompOption
def_comp_option = REOptions -> CompOption
forall r c e. REOptions_ r c e -> c
optionsComp REOptions
defaultREOptions
def_exec_option :: ExecOption
def_exec_option :: ExecOption
def_exec_option = REOptions -> ExecOption
forall r c e. REOptions_ r c e -> e
optionsExec REOptions
defaultREOptions