module Text.Regex.Do.Match.Latin
    (MatchOnce(..),
    MatchAll(..),
    R.extract   
    ) where
import Data.Tagged
import qualified Text.Regex.Base.RegexLike as R hiding (makeRegex)
import Text.Regex.Do.Type.Do
import Text.Regex.Do.Match.Matchf as F
import Text.Regex.Do.Match.Regex as R
import Text.Regex.Do.Type.Reexport as Re
import Text.Regex.Do.Type.Internal
class MatchOnce pattern body out where
    (~?)::pattern -> body -> out
class MatchAll pattern body out where
    (~*)::pattern -> body -> out
instance R.RegexLike Re.Regex b => MatchOnce Re.Regex b [b]  where
    ~? :: Regex -> b -> [b]
(~?) pat0 :: Regex
pat0 body0 :: b
body0 = Regex -> Tagged Once b -> [b]
forall b. (R_ b, Extract b) => Regex -> Tagged Once b -> [b]
once Regex
pat0 (b -> Tagged Once b
forall k (s :: k) b. b -> Tagged s b
Tagged b
body0)
instance (R.Regex b, R.RegexLike Re.Regex b) => 
        MatchOnce b b (E [b])  where     
    ~? :: b -> b -> E [b]
(~?) pat0 :: b
pat0 body0 :: b
body0 = b -> Tagged Once b -> (Regex -> Tagged Once b -> [b]) -> E [b]
forall a b (hint :: * -> *) out.
(Regex a, RegexLike Regex b) =>
a -> hint b -> (Regex -> hint b -> out) -> E out
withRegex b
pat0 (b -> Tagged Once b
forall k (s :: k) b. b -> Tagged s b
Tagged b
body0) Regex -> Tagged Once b -> [b]
forall b. (R_ b, Extract b) => Regex -> Tagged Once b -> [b]
once
instance (R.Regex b, R.RegexLike Re.Regex b) =>
        MatchOnce b b (E Bool) where
    ~? :: b -> b -> E Bool
(~?) pat0 :: b
pat0 body0 :: b
body0 = b -> Tagged Test b -> (Regex -> Tagged Test b -> Bool) -> E Bool
forall a b (hint :: * -> *) out.
(Regex a, RegexLike Regex b) =>
a -> hint b -> (Regex -> hint b -> out) -> E out
withRegex b
pat0 (b -> Tagged Test b
tagB b
body0) Regex -> Tagged Test b -> Bool
forall b. (R_ b, Extract b) => Regex -> Tagged Test b -> Bool
test
        where tagB::b -> Tagged Test b
              tagB :: b -> Tagged Test b
tagB = b -> Tagged Test b
forall k (s :: k) b. b -> Tagged s b
Tagged
              
instance R.RegexLike Re.Regex b =>
        MatchOnce Re.Regex b Bool where
    ~? :: Regex -> b -> Bool
(~?) pat0 :: Regex
pat0 body0 :: b
body0 = Regex -> Tagged Test b -> Bool
forall b. (R_ b, Extract b) => Regex -> Tagged Test b -> Bool
test Regex
pat0 (b -> Tagged Test b
tagB b
body0) 
        where tagB::b -> Tagged Test b
              tagB :: b -> Tagged Test b
tagB = b -> Tagged Test b
forall k (s :: k) b. b -> Tagged s b
Tagged    
               
instance R.RegexLike Re.Regex b =>
    MatchAll Re.Regex b [[b]] where
    ~* :: Regex -> b -> [[b]]
(~*) pat0 :: Regex
pat0 body0 :: b
body0 = Regex -> Tagged All b -> [[b]]
forall b. (R_ b, Extract b) => Regex -> Tagged All b -> [[b]]
F.all Regex
pat0 (b -> Tagged All b
forall k (s :: k) b. b -> Tagged s b
Tagged b
body0)
instance (R.Regex b, R.RegexLike Re.Regex b) =>
        MatchAll b b (E [[b]]) where
    ~* :: b -> b -> E [[b]]
(~*) pat0 :: b
pat0 body0 :: b
body0 = b -> Tagged All b -> (Regex -> Tagged All b -> [[b]]) -> E [[b]]
forall a b (hint :: * -> *) out.
(Regex a, RegexLike Regex b) =>
a -> hint b -> (Regex -> hint b -> out) -> E out
withRegex b
pat0 (b -> Tagged All b
forall k (s :: k) b. b -> Tagged s b
Tagged b
body0) Regex -> Tagged All b -> [[b]]
forall b. (R_ b, Extract b) => Regex -> Tagged All b -> [[b]]
F.all 
instance R.RegexLike Re.Regex b =>
        MatchOnce Re.Regex b [PosLen] where
    ~? :: Regex -> b -> [PosLen]
(~?) pat0 :: Regex
pat0 body0 :: b
body0 = [PosLen]
r1 
      where tagOne::b -> Tagged Once b
            tagOne :: b -> Tagged Once b
tagOne = b -> Tagged Once b
forall k (s :: k) b. b -> Tagged s b
Tagged
            Right r1 :: [PosLen]
r1 = E Regex -> Tagged Once b -> P (Tagged Once)
forall (hint :: * -> *) b.
(Matchf hint, R_ b) =>
E Regex -> hint b -> P hint
poslen_ (Regex -> E Regex
forall a b. b -> Either a b
Right Regex
pat0) (b -> Tagged Once b
tagOne b
body0)
instance (R.Regex b, R.RegexLike Re.Regex b) =>
        MatchOnce b b (E [PosLen]) where
    ~? :: b -> b -> Either String [PosLen]
(~?) pat0 :: b
pat0 body0 :: b
body0 = b
-> Tagged Once b
-> (E Regex -> Tagged Once b -> P (Tagged Once))
-> P (Tagged Once)
forall a (hint :: * -> *) b.
(Regex a, Matchf hint) =>
a -> hint b -> (E Regex -> hint b -> P hint) -> P hint
withRegex' b
pat0 (b -> Tagged Once b
tagOne b
body0) E Regex -> Tagged Once b -> P (Tagged Once)
forall (hint :: * -> *) b.
(Matchf hint, R_ b) =>
E Regex -> hint b -> P hint
poslen_
      where tagOne::b -> Tagged Once b
            tagOne :: b -> Tagged Once b
tagOne = b -> Tagged Once b
forall k (s :: k) b. b -> Tagged s b
Tagged
      
instance R.RegexLike Re.Regex b =>
        MatchAll Re.Regex b [[PosLen]] where
    ~* :: Regex -> b -> [[PosLen]]
(~*) pat0 :: Regex
pat0 body0 :: b
body0 = [[PosLen]]
r1 
      where tagAll::b -> Tagged All b
            tagAll :: b -> Tagged All b
tagAll = b -> Tagged All b
forall k (s :: k) b. b -> Tagged s b
Tagged
            Right r1 :: [[PosLen]]
r1 = E Regex -> Tagged All b -> P (Tagged All)
forall (hint :: * -> *) b.
(Matchf hint, R_ b) =>
E Regex -> hint b -> P hint
poslen_ (Regex -> E Regex
forall a b. b -> Either a b
Right Regex
pat0) (b -> Tagged All b
tagAll b
body0)
instance (R.Regex b, R.RegexLike Re.Regex b) =>
        MatchAll b b (E [[PosLen]]) where
    ~* :: b -> b -> Either String [[PosLen]]
(~*) pat0 :: b
pat0 body0 :: b
body0 = b
-> Tagged All b
-> (E Regex -> Tagged All b -> P (Tagged All))
-> P (Tagged All)
forall a (hint :: * -> *) b.
(Regex a, Matchf hint) =>
a -> hint b -> (E Regex -> hint b -> P hint) -> P hint
withRegex' b
pat0 (b -> Tagged All b
tagAll b
body0) E Regex -> Tagged All b -> P (Tagged All)
forall (hint :: * -> *) b.
(Matchf hint, R_ b) =>
E Regex -> hint b -> P hint
poslen_
      where tagAll::b -> Tagged All b
            tagAll :: b -> Tagged All b
tagAll = b -> Tagged All b
forall k (s :: k) b. b -> Tagged s b
Tagged
withRegex::(R.Regex a, R.RegexLike Re.Regex b) =>
    a ->        
    hint b ->   
    (Re.Regex -> hint b -> out) -> 
        E out
withRegex :: a -> hint b -> (Regex -> hint b -> out) -> E out
withRegex p0 :: a
p0 b0 :: hint b
b0 fn0 :: Regex -> hint b -> out
fn0 = a -> E Regex
forall a. Regex a => a -> E Regex
makeRegex a
p0 E Regex -> (Regex -> E out) -> E out
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \p1 :: Regex
p1 ->
        out -> E out
forall a b. b -> Either a b
Right (out -> E out) -> out -> E out
forall a b. (a -> b) -> a -> b
$ Regex -> hint b -> out
fn0 Regex
p1 hint b
b0
withRegex'::(R.Regex a, Matchf hint) =>
    a -> hint b ->
        (E Re.Regex -> hint b -> P hint) ->
        P hint
withRegex' :: a -> hint b -> (E Regex -> hint b -> P hint) -> P hint
withRegex' p0 :: a
p0 b0 :: hint b
b0 fn0 :: E Regex -> hint b -> P hint
fn0 = 
        let er1 :: E Regex
er1 = a -> E Regex
forall a. Regex a => a -> E Regex
makeRegex a
p0 
        in E Regex -> hint b -> P hint
fn0 E Regex
er1 hint b
b0