    {-# LANGUAGE NoImplicitPrelude          #-}
    {-# LANGUAGE RecordWildCards            #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE OverloadedStrings          #-}
    {-# LANGUAGE CPP                        #-}
    #if __GLASGOW_HASKELL__ >= 800
    {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
    #endif

    module Text.RE.ZeInternals.PreludeMacros
      ( RegexType
      , WithCaptures(..)
      , MacroDescriptor(..)
      , RegexSource(..)
      , PreludeMacro(..)
      , presentPreludeMacro
      , preludeMacros
      , preludeMacroTable
      , preludeMacroSummary
      , preludeMacroSources
      , preludeMacroSource
      , preludeMacroEnv
      , preludeMacroDescriptor
      ) where

    import           Data.Array
    import qualified Data.HashMap.Lazy            as HML
    import           Data.List
    import           Data.Maybe
    import qualified Data.Text                    as T
    import           Data.Time
    import           Prelude.Compat
    import           Text.RE.REOptions
    import           Text.RE.ZeInternals.TestBench
    import           Text.RE.ZeInternals.TestBench.Parsers

    -- | generate the standard prelude Macros used to parse REs
    preludeMacros :: (Monad m,Functor m)
                  => (String->m r)
                  -> RegexType
                  -> WithCaptures
                  -> m (Macros r)
    preludeMacros :: forall (m :: * -> *) r.
    (Monad m, Functor m) =>
    ([Char] -> m r) -> RegexType -> WithCaptures -> m (Macros r)
    preludeMacros [Char] -> m r
    prs RegexType
    rty WithCaptures
    wc = ([Char] -> m r)
    -> RegexType -> WithCaptures -> MacroEnv -> m (Macros r)
    forall (m :: * -> *) r.
    (Monad m, Functor m) =>
    ([Char] -> m r)
    -> RegexType -> WithCaptures -> MacroEnv -> m (Macros r)
    mkMacros [Char] -> m r
    prs RegexType
    rty WithCaptures
    wc (MacroEnv -> m (Macros r)) -> MacroEnv -> m (Macros r)
    forall a b. (a -> b) -> a -> b
    $ RegexType -> MacroEnv
    preludeMacroEnv RegexType
    rty

    -- | format the standard prelude macros in a markdown table
    preludeMacroTable :: RegexType -> String
    preludeMacroTable :: RegexType -> [Char]
    preludeMacroTable RegexType
    rty = RegexType -> MacroEnv -> [Char]
    formatMacroTable RegexType
    rty (MacroEnv -> [Char]) -> MacroEnv -> [Char]
    forall a b. (a -> b) -> a -> b
    $ RegexType -> MacroEnv
    preludeMacroEnv RegexType
    rty

    -- | generate a textual summary of the prelude macros
    preludeMacroSummary :: RegexType -> PreludeMacro -> String
    preludeMacroSummary :: RegexType -> PreludeMacro -> [Char]
    preludeMacroSummary RegexType
    rty =
      RegexType -> MacroEnv -> MacroID -> [Char]
    formatMacroSummary RegexType
    rty (RegexType -> MacroEnv
    preludeMacroEnv RegexType
    rty) (MacroID -> [Char])
    -> (PreludeMacro -> MacroID) -> PreludeMacro -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PreludeMacro -> MacroID
    prelude_macro_id

    -- | generate a plain text table giving the RE for each macro with all
    -- macros expanded (to NF)
    preludeMacroSources :: RegexType -> String
    preludeMacroSources :: RegexType -> [Char]
    preludeMacroSources RegexType
    rty =
      RegexType -> WithCaptures -> MacroEnv -> [Char]
    formatMacroSources RegexType
    rty WithCaptures
    ExclCaptures (MacroEnv -> [Char]) -> MacroEnv -> [Char]
    forall a b. (a -> b) -> a -> b
    $ RegexType -> MacroEnv
    preludeMacroEnv RegexType
    rty

    -- | generate plain text giving the expanded RE for a single macro
    preludeMacroSource :: RegexType -> PreludeMacro -> String
    preludeMacroSource :: RegexType -> PreludeMacro -> [Char]
    preludeMacroSource RegexType
    rty =
      RegexType -> WithCaptures -> MacroEnv -> MacroID -> [Char]
    formatMacroSource RegexType
    rty WithCaptures
    ExclCaptures (RegexType -> MacroEnv
    preludeMacroEnv RegexType
    rty) (MacroID -> [Char])
    -> (PreludeMacro -> MacroID) -> PreludeMacro -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PreludeMacro -> MacroID
    prelude_macro_id

    -- | generate the `MacroEnv` for the standard prelude macros
    preludeMacroEnv :: RegexType -> MacroEnv
    preludeMacroEnv :: RegexType -> MacroEnv
    preludeMacroEnv RegexType
    rty = (MacroEnv -> MacroEnv) -> MacroEnv
    forall a. (a -> a) -> a
    fix ((MacroEnv -> MacroEnv) -> MacroEnv)
    -> (MacroEnv -> MacroEnv) -> MacroEnv
    forall a b. (a -> b) -> a -> b
    $ RegexType -> MacroEnv -> MacroEnv
    prelude_macro_env RegexType
    rty

    prelude_macro_env :: RegexType -> MacroEnv -> MacroEnv
    prelude_macro_env :: RegexType -> MacroEnv -> MacroEnv
    prelude_macro_env RegexType
    rty MacroEnv
    env = [(MacroID, MacroDescriptor)] -> MacroEnv
    forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
    HML.fromList ([(MacroID, MacroDescriptor)] -> MacroEnv)
    -> [(MacroID, MacroDescriptor)] -> MacroEnv
    forall a b. (a -> b) -> a -> b
    $ [Maybe (MacroID, MacroDescriptor)] -> [(MacroID, MacroDescriptor)]
    forall a. [Maybe a] -> [a]
    catMaybes
      [ (,) (PreludeMacro -> MacroID
    prelude_macro_id PreludeMacro
    pm) (MacroDescriptor -> (MacroID, MacroDescriptor))
    -> Maybe MacroDescriptor -> Maybe (MacroID, MacroDescriptor)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    preludeMacroDescriptor RegexType
    rty MacroEnv
    env PreludeMacro
    pm
          | PreludeMacro
    pm<-[PreludeMacro
    forall a. Bounded a => a
    minBound..PreludeMacro
    forall a. Bounded a => a
    maxBound]
          ]

    -- | generate the `MacroDescriptor` for a given `PreludeMacro`
    preludeMacroDescriptor :: RegexType
                           -> MacroEnv
                           -> PreludeMacro
                           -> Maybe MacroDescriptor
    preludeMacroDescriptor :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    preludeMacroDescriptor RegexType
    rty MacroEnv
    env PreludeMacro
    pm = case PreludeMacro
    pm of
      PreludeMacro
    PM_nat              -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    natural_macro          RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_hex              -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    natural_hex_macro      RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_int              -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    integer_macro          RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_frac             -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    decimal_macro          RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_string           -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    string_macro           RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_string_simple    -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    string_simple_macro    RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_id               -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    id_macro               RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_id'              -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    id'_macro              RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_id_              -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    id__macro              RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_date             -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    date_macro             RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_date_slashes     -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    date_slashes_macro     RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_time             -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    time_macro             RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_timezone         -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    timezone_macro         RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_datetime         -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    datetime_macro         RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_datetime_8601    -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    datetime_8601_macro    RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_datetime_clf     -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    datetime_clf_macro     RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_shortmonth       -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    shortmonth_macro       RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_address_ipv4     -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    address_ipv4_macros    RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_email_simple     -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    email_simple_macro     RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_url              -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    url_macro              RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      PreludeMacro
    PM_syslog_severity  -> RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    syslog_severity_macro  RegexType
    rty MacroEnv
    env PreludeMacro
    pm

    -- | an enumeration of all of the prelude macros
    data PreludeMacro
      -- numbers
      = PM_nat
      | PM_hex
      | PM_int
      | PM_frac
      -- strings
      | PM_string
      | PM_string_simple
      -- identifiers
      | PM_id
      | PM_id'
      | PM_id_
      -- dates & times
      | PM_date
      | PM_date_slashes
      | PM_time
      | PM_timezone
      | PM_datetime
      | PM_datetime_8601
      | PM_datetime_clf
      | PM_shortmonth
      -- addresses
      | PM_address_ipv4
      | PM_email_simple
      | PM_url
      -- syslog
      | PM_syslog_severity
      deriving (PreludeMacro
    PreludeMacro -> PreludeMacro -> Bounded PreludeMacro
    forall a. a -> a -> Bounded a
    $cminBound :: PreludeMacro
    minBound :: PreludeMacro
    $cmaxBound :: PreludeMacro
    maxBound :: PreludeMacro
    Bounded,Int -> PreludeMacro
    PreludeMacro -> Int
    PreludeMacro -> [PreludeMacro]
    PreludeMacro -> PreludeMacro
    PreludeMacro -> PreludeMacro -> [PreludeMacro]
    PreludeMacro -> PreludeMacro -> PreludeMacro -> [PreludeMacro]
    (PreludeMacro -> PreludeMacro)
    -> (PreludeMacro -> PreludeMacro)
    -> (Int -> PreludeMacro)
    -> (PreludeMacro -> Int)
    -> (PreludeMacro -> [PreludeMacro])
    -> (PreludeMacro -> PreludeMacro -> [PreludeMacro])
    -> (PreludeMacro -> PreludeMacro -> [PreludeMacro])
    -> (PreludeMacro -> PreludeMacro -> PreludeMacro -> [PreludeMacro])
    -> Enum PreludeMacro
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: PreludeMacro -> PreludeMacro
    succ :: PreludeMacro -> PreludeMacro
    $cpred :: PreludeMacro -> PreludeMacro
    pred :: PreludeMacro -> PreludeMacro
    $ctoEnum :: Int -> PreludeMacro
    toEnum :: Int -> PreludeMacro
    $cfromEnum :: PreludeMacro -> Int
    fromEnum :: PreludeMacro -> Int
    $cenumFrom :: PreludeMacro -> [PreludeMacro]
    enumFrom :: PreludeMacro -> [PreludeMacro]
    $cenumFromThen :: PreludeMacro -> PreludeMacro -> [PreludeMacro]
    enumFromThen :: PreludeMacro -> PreludeMacro -> [PreludeMacro]
    $cenumFromTo :: PreludeMacro -> PreludeMacro -> [PreludeMacro]
    enumFromTo :: PreludeMacro -> PreludeMacro -> [PreludeMacro]
    $cenumFromThenTo :: PreludeMacro -> PreludeMacro -> PreludeMacro -> [PreludeMacro]
    enumFromThenTo :: PreludeMacro -> PreludeMacro -> PreludeMacro -> [PreludeMacro]
    Enum,Eq PreludeMacro
    Eq PreludeMacro =>
    (PreludeMacro -> PreludeMacro -> Ordering)
    -> (PreludeMacro -> PreludeMacro -> Bool)
    -> (PreludeMacro -> PreludeMacro -> Bool)
    -> (PreludeMacro -> PreludeMacro -> Bool)
    -> (PreludeMacro -> PreludeMacro -> Bool)
    -> (PreludeMacro -> PreludeMacro -> PreludeMacro)
    -> (PreludeMacro -> PreludeMacro -> PreludeMacro)
    -> Ord PreludeMacro
    PreludeMacro -> PreludeMacro -> Bool
    PreludeMacro -> PreludeMacro -> Ordering
    PreludeMacro -> PreludeMacro -> PreludeMacro
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: PreludeMacro -> PreludeMacro -> Ordering
    compare :: PreludeMacro -> PreludeMacro -> Ordering
    $c< :: PreludeMacro -> PreludeMacro -> Bool
    < :: PreludeMacro -> PreludeMacro -> Bool
    $c<= :: PreludeMacro -> PreludeMacro -> Bool
    <= :: PreludeMacro -> PreludeMacro -> Bool
    $c> :: PreludeMacro -> PreludeMacro -> Bool
    > :: PreludeMacro -> PreludeMacro -> Bool
    $c>= :: PreludeMacro -> PreludeMacro -> Bool
    >= :: PreludeMacro -> PreludeMacro -> Bool
    $cmax :: PreludeMacro -> PreludeMacro -> PreludeMacro
    max :: PreludeMacro -> PreludeMacro -> PreludeMacro
    $cmin :: PreludeMacro -> PreludeMacro -> PreludeMacro
    min :: PreludeMacro -> PreludeMacro -> PreludeMacro
    Ord,PreludeMacro -> PreludeMacro -> Bool
    (PreludeMacro -> PreludeMacro -> Bool)
    -> (PreludeMacro -> PreludeMacro -> Bool) -> Eq PreludeMacro
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: PreludeMacro -> PreludeMacro -> Bool
    == :: PreludeMacro -> PreludeMacro -> Bool
    $c/= :: PreludeMacro -> PreludeMacro -> Bool
    /= :: PreludeMacro -> PreludeMacro -> Bool
    Eq,Int -> PreludeMacro -> [Char] -> [Char]
    [PreludeMacro] -> [Char] -> [Char]
    PreludeMacro -> [Char]
    (Int -> PreludeMacro -> [Char] -> [Char])
    -> (PreludeMacro -> [Char])
    -> ([PreludeMacro] -> [Char] -> [Char])
    -> Show PreludeMacro
    forall a.
    (Int -> a -> [Char] -> [Char])
    -> (a -> [Char]) -> ([a] -> [Char] -> [Char]) -> Show a
    $cshowsPrec :: Int -> PreludeMacro -> [Char] -> [Char]
    showsPrec :: Int -> PreludeMacro -> [Char] -> [Char]
    $cshow :: PreludeMacro -> [Char]
    show :: PreludeMacro -> [Char]
    $cshowList :: [PreludeMacro] -> [Char] -> [Char]
    showList :: [PreludeMacro] -> [Char] -> [Char]
    Show)

    -- | naming the macros
    presentPreludeMacro :: PreludeMacro -> String
    presentPreludeMacro :: PreludeMacro -> [Char]
    presentPreludeMacro PreludeMacro
    pm = case PreludeMacro
    pm of
        PreludeMacro
    PM_id_  -> [Char]
    prelude_prefix[Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++[Char]
    "id-"
        PreludeMacro
    _       -> PreludeMacro -> [Char]
    fmt PreludeMacro
    pm
      where
        fmt :: PreludeMacro -> [Char]
    fmt = ([Char]
    prelude_prefix[Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++) ([Char] -> [Char])
    -> (PreludeMacro -> [Char]) -> PreludeMacro -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Char -> Char) -> [Char] -> [Char]
    forall a b. (a -> b) -> [a] -> [b]
    map Char -> Char
    tr ([Char] -> [Char])
    -> (PreludeMacro -> [Char]) -> PreludeMacro -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> [Char] -> [Char]
    forall a. Int -> [a] -> [a]
    drop Int
    3 ([Char] -> [Char])
    -> (PreludeMacro -> [Char]) -> PreludeMacro -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PreludeMacro -> [Char]
    forall a. Show a => a -> [Char]
    show

        tr :: Char -> Char
    tr Char
    '_' = Char
    '.'
        tr Char
    c   = Char
    c

    -- | all prelude macros are prefixed with this
    prelude_prefix :: String
    prelude_prefix :: [Char]
    prelude_prefix = [Char]
    "%"

    prelude_macro_id :: PreludeMacro -> MacroID
    prelude_macro_id :: PreludeMacro -> MacroID
    prelude_macro_id = [Char] -> MacroID
    MacroID ([Char] -> MacroID)
    -> (PreludeMacro -> [Char]) -> PreludeMacro -> MacroID
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PreludeMacro -> [Char]
    presentPreludeMacro

    natural_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    natural_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    natural_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm = MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe Int)
    -> [([Char], Int)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe Int
    forall a. Replace a => a -> Maybe Int
    parseInteger [([Char], Int)]
    samples MacroEnv
    env PreludeMacro
    pm
      MacroDescriptor
        { macroSource :: RegexSource
    macroSource          = RegexSource
    "[0-9]+"
        , macroSamples :: [[Char]]
    macroSamples         = (([Char], Int) -> [Char]) -> [([Char], Int)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], Int) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], Int)]
    samples
        , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
        , macroTestResults :: [TestResult]
    macroTestResults    = []
        , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseInteger"
        , macroDescription :: [Char]
    macroDescription     = [Char]
    "a string of one or more decimal digits"
        }
      where
        samples :: [(String,Int)]
        samples :: [([Char], Int)]
    samples =
          [ (,) [Char]
    "0"          Int
    0
          , (,) [Char]
    "1234567890" Int
    1234567890
          , (,) [Char]
    "00"         Int
    0
          , (,) [Char]
    "01"         Int
    1
          ]

        counter_samples :: [[Char]]
    counter_samples =
          [ [Char]
    ""
          , [Char]
    "0A"
          , [Char]
    "-1"
          ]

    natural_hex_macro :: RegexType
                      -> MacroEnv
                      -> PreludeMacro
                      -> Maybe MacroDescriptor
    natural_hex_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    natural_hex_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm = MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe Int)
    -> [([Char], Int)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe Int
    forall a. Replace a => a -> Maybe Int
    parseHex [([Char], Int)]
    samples MacroEnv
    env PreludeMacro
    pm
      MacroDescriptor
        { macroSource :: RegexSource
    macroSource          = RegexSource
    "[0-9a-fA-F]+"
        , macroSamples :: [[Char]]
    macroSamples         = (([Char], Int) -> [Char]) -> [([Char], Int)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], Int) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], Int)]
    samples
        , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
        , macroTestResults :: [TestResult]
    macroTestResults    = []
        , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseHex"
        , macroDescription :: [Char]
    macroDescription     = [Char]
    "a string of one or more hexadecimal digits"
        }
      where
        samples :: [(String,Int)]
        samples :: [([Char], Int)]
    samples =
          [ (,) [Char]
    "0"         Int
    0x0
          , (,) [Char]
    "12345678"  Int
    0x12345678
          , (,) [Char]
    "0abcdef"   Int
    0xabcdef
          , (,) [Char]
    "0ABCDEF"   Int
    0xabcdef
          , (,) [Char]
    "00"        Int
    0x0
          , (,) [Char]
    "010"       Int
    0x10
          ]

        counter_samples :: [[Char]]
    counter_samples =
          [ [Char]
    ""
          , [Char]
    "0x10"
          , [Char]
    "0z"
          , [Char]
    "-1a"
          ]

    integer_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    integer_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    integer_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm = MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe Int)
    -> [([Char], Int)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe Int
    forall a. Replace a => a -> Maybe Int
    parseInteger [([Char], Int)]
    samples MacroEnv
    env PreludeMacro
    pm
      MacroDescriptor
        { macroSource :: RegexSource
    macroSource          = RegexSource
    "-?[0-9]+"
        , macroSamples :: [[Char]]
    macroSamples         = (([Char], Int) -> [Char]) -> [([Char], Int)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], Int) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], Int)]
    samples
        , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
        , macroTestResults :: [TestResult]
    macroTestResults    = []
        , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseInteger"
        , macroDescription :: [Char]
    macroDescription     = [Char]
    "a decimal integer"
        }
      where
        samples :: [(String,Int)]
        samples :: [([Char], Int)]
    samples =
          [ (,) [Char]
    "0"           Int
    0
          , (,) [Char]
    "1234567890"  Int
    1234567890
          , (,) [Char]
    "00"          Int
    0
          , (,) [Char]
    "01"          Int
    1
          , (,) [Char]
    "-1"       (Int -> ([Char], Int)) -> Int -> ([Char], Int)
    forall a b. (a -> b) -> a -> b
    $ -Int
    1
          , (,) [Char]
    "-0"          Int
    0
          ]

        counter_samples :: [[Char]]
    counter_samples =
          [ [Char]
    ""
          , [Char]
    "0A"
          , [Char]
    "+0"
          ]

    -- | a digit string macro
    decimal_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    decimal_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    decimal_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm = MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe Double)
    -> [([Char], Double)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe Double
    forall a. Replace a => a -> Maybe Double
    parseDouble [([Char], Double)]
    samples MacroEnv
    env PreludeMacro
    pm
      MacroDescriptor
        { macroSource :: RegexSource
    macroSource          = RegexSource
    "-?[0-9]+(?:\\.[0-9]+)?"
        , macroSamples :: [[Char]]
    macroSamples         = (([Char], Double) -> [Char]) -> [([Char], Double)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], Double) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], Double)]
    samples
        , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
        , macroTestResults :: [TestResult]
    macroTestResults    = []
        , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseInteger"
        , macroDescription :: [Char]
    macroDescription     = [Char]
    "a decimal natural number"
        }
      where
        samples :: [(String,Double)]
        samples :: [([Char], Double)]
    samples =
          [ (,) [Char]
    "0"             Double
    0
          , (,) [Char]
    "1234567890"    Double
    1234567890
          , (,) [Char]
    "00"            Double
    0
          , (,) [Char]
    "01"            Double
    1
          , (,) [Char]
    "-1"         (Double -> ([Char], Double)) -> Double -> ([Char], Double)
    forall a b. (a -> b) -> a -> b
    $ -Double
    1
          , (,) [Char]
    "-0"            Double
    0
          , (,) [Char]
    "0.1234567890"  Double
    0.1234567890
          , (,) [Char]
    "-1.0"       (Double -> ([Char], Double)) -> Double -> ([Char], Double)
    forall a b. (a -> b) -> a -> b
    $ -Double
    1.0
          ]

        counter_samples :: [[Char]]
    counter_samples =
          [ [Char]
    ""
          , [Char]
    "0A"
          , [Char]
    "+0"
          , [Char]
    "0."
          , [Char]
    ".0"
          , [Char]
    "."
          , [Char]
    "-"
          , [Char]
    "-."
          , [Char]
    "-1."
          , [Char]
    "-.1"
          ]

    string_macro :: RegexType
                 -> MacroEnv
                 -> PreludeMacro
                 -> Maybe MacroDescriptor
    string_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    string_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm
      | RegexType -> Bool
    isPCRE RegexType
    rty = Maybe MacroDescriptor
    forall a. Maybe a
    Nothing
      | Bool
    otherwise  =
        MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe [Char])
    -> [([Char], [Char])]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty ((Text -> [Char]) -> Maybe Text -> Maybe [Char]
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Text -> [Char]
    T.unpack (Maybe Text -> Maybe [Char])
    -> ([Char] -> Maybe Text) -> [Char] -> Maybe [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Maybe Text
    forall a. Replace a => a -> Maybe Text
    parseString) [([Char], [Char])]
    samples MacroEnv
    env PreludeMacro
    pm
          MacroDescriptor
            { macroSource :: RegexSource
    macroSource          = RegexSource
    "\"(?:[^\"\\]+|\\\\[\\\"])*\""
            , macroSamples :: [[Char]]
    macroSamples         = (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], [Char]) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], [Char])]
    samples
            , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
            , macroTestResults :: [TestResult]
    macroTestResults    = []
            , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseString"
            , macroDescription :: [Char]
    macroDescription     = [Char]
    "a double-quote string, with simple \\ escapes for \\s and \"s"
            }
      where
        samples :: [(String,String)]
        samples :: [([Char], [Char])]
    samples =
          [ (,) [Char]
    "\"\""                [Char]
    ""
          , (,) [Char]
    "\"foo\""             [Char]
    "foo"
          , (,) [Char]
    "\"\\\"\""            [Char]
    "\""
          , (,) [Char]
    "\"\\\"\\\"\""        [Char]
    "\"\""
          , (,) [Char]
    "\"\\\"\\\\\\\"\""    [Char]
    "\"\\\""
          , (,) [Char]
    "\"\\\"foo\\\"\""     [Char]
    "\"foo\""
          , (,) [Char]
    "\"\""                [Char]
    ""
          ]

        counter_samples :: [[Char]]
    counter_samples =
          [ [Char]
    "\""
          , [Char]
    "\"aa"
          ]

    string_simple_macro :: RegexType
                        -> MacroEnv
                        -> PreludeMacro
                        -> Maybe MacroDescriptor
    string_simple_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    string_simple_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe [Char])
    -> [([Char], [Char])]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty ((Text -> [Char]) -> Maybe Text -> Maybe [Char]
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Text -> [Char]
    T.unpack (Maybe Text -> Maybe [Char])
    -> ([Char] -> Maybe Text) -> [Char] -> Maybe [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Maybe Text
    forall a. Replace a => a -> Maybe Text
    parseSimpleString) [([Char], [Char])]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "\"[^\"[:cntrl:]]*\""
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], [Char]) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], [Char])]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseSimpleString"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "a simple quoted string"
          }
      where
        samples :: [(String,String)]
        samples :: [([Char], [Char])]
    samples =
          [ (,) [Char]
    "\"\""      [Char]
    ""
          , (,) [Char]
    "\"foo\""   [Char]
    "foo"
          , (,) [Char]
    "\"\\\""    [Char]
    "\\"
          , (,) [Char]
    "\"\""      [Char]
    ""
          ]

        counter_samples :: [[Char]]
    counter_samples =
          [ [Char]
    ""
          , [Char]
    "\""
          , [Char]
    "\"\\\"\""
          , [Char]
    "\"\\\"\\\"\""
          , [Char]
    "\"\\\"\\\\\\\"\""
          , [Char]
    "\"\\\"foo\\\"\""
          , [Char]
    "\"aa"
          ]

    id_macro :: RegexType
             -> MacroEnv
             -> PreludeMacro
             -> Maybe MacroDescriptor
    id_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    id_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe [Char])
    -> [([Char], [Char])]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe [Char]
    forall a. a -> Maybe a
    Just [([Char], [Char])]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "_*[a-zA-Z][a-zA-Z0-9_]*"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], [Char]) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], [Char])]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = Maybe FunctionID
    forall a. Maybe a
    Nothing
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "a standard C-style alphanumeric identifier (with _s)"
          }
      where
        samples :: [(String,String)]
        samples :: [([Char], [Char])]
    samples =
            [ [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "A"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "A1"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a_"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a1_B2"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "_abc"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "__abc"
            ]
          where
            f :: b -> (b, b)
    f b
    s = (b
    s,b
    s)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "1"
            , [Char]
    "_"
            , [Char]
    "__"
            , [Char]
    "__1"
            , [Char]
    "1a"
            , [Char]
    "a'"
            ]

    id'_macro :: RegexType
              -> MacroEnv
              -> PreludeMacro
              -> Maybe MacroDescriptor
    id'_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    id'_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe [Char])
    -> [([Char], [Char])]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe [Char]
    forall a. a -> Maybe a
    Just [([Char], [Char])]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "_*[a-zA-Z][a-zA-Z0-9_']*"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], [Char]) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], [Char])]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = Maybe FunctionID
    forall a. Maybe a
    Nothing
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "a standard Haskell-style alphanumeric identifier (with '_'s and '''s)"
          }
      where
        samples :: [(String,String)]
        samples :: [([Char], [Char])]
    samples =
            [ [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "A"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "A1"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a_"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a1_B2"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "_abc"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "__abc"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a'"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "_a'"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a'b"
            ]
          where
            f :: b -> (b, b)
    f b
    s = (b
    s,b
    s)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "1"
            , [Char]
    "_"
            , [Char]
    "__"
            , [Char]
    "__1"
            , [Char]
    "1a"
            , [Char]
    "'"
            , [Char]
    "'a"
            , [Char]
    "_'"
            , [Char]
    "_1'"
            ]

    id__macro :: RegexType
              -> MacroEnv
              -> PreludeMacro
              -> Maybe MacroDescriptor
    id__macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    id__macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe [Char])
    -> [([Char], [Char])]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe [Char]
    forall a. a -> Maybe a
    Just [([Char], [Char])]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "_*[a-zA-Z][a-zA-Z0-9_'-]*"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], [Char]) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], [Char])]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = Maybe FunctionID
    forall a. Maybe a
    Nothing
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "an identifier with -s"
          }
      where
        samples :: [(String,String)]
        samples :: [([Char], [Char])]
    samples =
            [ [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "A"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "A1"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a_"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a1_B2"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "_abc"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "__abc"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a'"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "_a'"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a'b"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a-"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a1-B2"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "a1-B2-"
            ]
          where
            f :: b -> (b, b)
    f b
    s = (b
    s,b
    s)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "1"
            , [Char]
    "_"
            , [Char]
    "__"
            , [Char]
    "__1"
            , [Char]
    "1a"
            , [Char]
    "'"
            , [Char]
    "'a"
            , [Char]
    "_'"
            , [Char]
    "_1'"
            ]

    date_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    date_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    date_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe Day)
    -> [([Char], Day)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe Day
    forall a. Replace a => a -> Maybe Day
    parseDate [([Char], Day)]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "[0-9]{4}-[0-9]{2}-[0-9]{2}"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], Day) -> [Char]) -> [([Char], Day)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], Day) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], Day)]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseDate"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "a YYYY-MM-DD format date"
          }
      where
        samples :: [(String,Day)]
        samples :: [([Char], Day)]
    samples =
            [ [Char] -> ([Char], Day)
    forall {b}. Read b => [Char] -> ([Char], b)
    f [Char]
    "2016-12-31"
            , [Char] -> ([Char], Day)
    forall {b}. Read b => [Char] -> ([Char], b)
    f [Char]
    "0001-01-01"
            , [Char] -> ([Char], Day)
    forall {b}. Read b => [Char] -> ([Char], b)
    f [Char]
    "1000-01-01"
            ]
          where
            f :: [Char] -> ([Char], b)
    f [Char]
    s = ([Char]
    s,[Char] -> b
    forall a. Read a => [Char] -> a
    read [Char]
    s)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "2016/01/31"
            , [Char]
    "2016-1-31"
            , [Char]
    "2016-01-1"
            , [Char]
    "2016-001-01"
            ]

    date_slashes_macro :: RegexType
                       -> MacroEnv
                       -> PreludeMacro
                       -> Maybe MacroDescriptor
    date_slashes_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    date_slashes_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe Day)
    -> [([Char], Day)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe Day
    forall a. Replace a => a -> Maybe Day
    parseSlashesDate [([Char], Day)]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "[0-9]{4}/[0-9]{2}/[0-9]{2}"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], Day) -> [Char]) -> [([Char], Day)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], Day) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], Day)]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseSlashesDate"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "a YYYY/MM/DD format date"
          }
      where
        samples :: [(String,Day)]
        samples :: [([Char], Day)]
    samples =
            [ [Char] -> ([Char], Day)
    forall {b}. Read b => [Char] -> ([Char], b)
    f [Char]
    "2016/12/31"
            , [Char] -> ([Char], Day)
    forall {b}. Read b => [Char] -> ([Char], b)
    f [Char]
    "0001/01/01"
            , [Char] -> ([Char], Day)
    forall {b}. Read b => [Char] -> ([Char], b)
    f [Char]
    "1000/01/01"
            ]
          where
            f :: [Char] -> ([Char], b)
    f [Char]
    s = ([Char]
    s,[Char] -> b
    forall a. Read a => [Char] -> a
    read ([Char] -> b) -> [Char] -> b
    forall a b. (a -> b) -> a -> b
    $ (Char -> Char) -> [Char] -> [Char]
    forall a b. (a -> b) -> [a] -> [b]
    map Char -> Char
    tr [Char]
    s)
              where
                tr :: Char -> Char
    tr Char
    '/' = Char
    '-'
                tr Char
    c   = Char
    c

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "2016-01-31"
            , [Char]
    "2016/1/31"
            , [Char]
    "2016/01/1"
            , [Char]
    "2016/001/01"
            ]

    time_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    time_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    time_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe TimeOfDay)
    -> [([Char], TimeOfDay)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe TimeOfDay
    forall a. Replace a => a -> Maybe TimeOfDay
    parseTimeOfDay [([Char], TimeOfDay)]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "[0-9]{2}:[0-9]{2}:[0-9]{2}(?:[.][0-9]+)?"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], TimeOfDay) -> [Char])
    -> [([Char], TimeOfDay)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], TimeOfDay) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], TimeOfDay)]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseTimeOfDay"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "a HH:MM:SS[.Q+]"
          }
      where
        samples :: [(String,TimeOfDay)]
        samples :: [([Char], TimeOfDay)]
    samples =
            [ [Char] -> Int -> Int -> Pico -> ([Char], TimeOfDay)
    forall {a}. a -> Int -> Int -> Pico -> (a, TimeOfDay)
    f [Char]
    "00:00:00"            Int
    00 Int
    00   Pico
    0
            , [Char] -> Int -> Int -> Pico -> ([Char], TimeOfDay)
    forall {a}. a -> Int -> Int -> Pico -> (a, TimeOfDay)
    f [Char]
    "23:59:59"            Int
    23 Int
    59   Pico
    59
            , [Char] -> Int -> Int -> Pico -> ([Char], TimeOfDay)
    forall {a}. a -> Int -> Int -> Pico -> (a, TimeOfDay)
    f [Char]
    "00:00:00.1234567890" Int
    00 Int
    00 (Pico -> ([Char], TimeOfDay)) -> Pico -> ([Char], TimeOfDay)
    forall a b. (a -> b) -> a -> b
    $ Pico
    123456789 Pico -> Pico -> Pico
    forall a. Fractional a => a -> a -> a
    / Pico
    1000000000
            ]
          where
            f :: a -> Int -> Int -> Pico -> (a, TimeOfDay)
    f a
    s Int
    h Int
    m Pico
    ps = (a
    s,Int -> Int -> Pico -> TimeOfDay
    TimeOfDay Int
    h Int
    m Pico
    ps)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "235959"
            , [Char]
    "10:20"
            , [Char]
    "A00:00:00"
            , [Char]
    "00:00:00A"
            , [Char]
    "23:59:59."
            ]

    timezone_macro :: RegexType
                   -> MacroEnv
                   -> PreludeMacro
                   -> Maybe MacroDescriptor
    timezone_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    timezone_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe TimeZone)
    -> [([Char], TimeZone)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe TimeZone
    forall a. Replace a => a -> Maybe TimeZone
    parseTimeZone [([Char], TimeZone)]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "(?:Z|[+-][0-9]{2}:?[0-9]{2})"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], TimeZone) -> [Char]) -> [([Char], TimeZone)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], TimeZone) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], TimeZone)]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseTimeZone"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "an IOS-8601 TZ specification"
          }
      where
        samples :: [(String,TimeZone)]
        samples :: [([Char], TimeZone)]
    samples =
            [ [Char] -> TimeZone -> ([Char], TimeZone)
    forall a b. a -> b -> (a, b)
    f [Char]
    "Z"         (TimeZone -> ([Char], TimeZone)) -> TimeZone -> ([Char], TimeZone)
    forall a b. (a -> b) -> a -> b
    $ Int -> TimeZone
    minutesToTimeZone     Int
    0
            , [Char] -> TimeZone -> ([Char], TimeZone)
    forall a b. a -> b -> (a, b)
    f [Char]
    "+00:00"    (TimeZone -> ([Char], TimeZone)) -> TimeZone -> ([Char], TimeZone)
    forall a b. (a -> b) -> a -> b
    $ Int -> TimeZone
    minutesToTimeZone     Int
    0
            , [Char] -> TimeZone -> ([Char], TimeZone)
    forall a b. a -> b -> (a, b)
    f [Char]
    "+0000"     (TimeZone -> ([Char], TimeZone)) -> TimeZone -> ([Char], TimeZone)
    forall a b. (a -> b) -> a -> b
    $ Int -> TimeZone
    minutesToTimeZone     Int
    0
            , [Char] -> TimeZone -> ([Char], TimeZone)
    forall a b. a -> b -> (a, b)
    f [Char]
    "+0200"     (TimeZone -> ([Char], TimeZone)) -> TimeZone -> ([Char], TimeZone)
    forall a b. (a -> b) -> a -> b
    $ Int -> TimeZone
    minutesToTimeZone   Int
    120
            , [Char] -> TimeZone -> ([Char], TimeZone)
    forall a b. a -> b -> (a, b)
    f [Char]
    "-0100"     (TimeZone -> ([Char], TimeZone)) -> TimeZone -> ([Char], TimeZone)
    forall a b. (a -> b) -> a -> b
    $ Int -> TimeZone
    minutesToTimeZone (Int -> TimeZone) -> Int -> TimeZone
    forall a b. (a -> b) -> a -> b
    $ -Int
    60
            ]
          where
            f :: a -> b -> (a, b)
    f = (,)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "00"
            , [Char]
    "A00:00"
            , [Char]
    "UTC"
            , [Char]
    "EST"
            , [Char]
    " EST"
            ]

    datetime_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    datetime_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    datetime_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm = MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe UTCTime)
    -> [([Char], UTCTime)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe UTCTime
    forall a. Replace a => a -> Maybe UTCTime
    parseDateTime [([Char], UTCTime)]
    samples MacroEnv
    env PreludeMacro
    pm
      MacroDescriptor
        { macroSource :: RegexSource
    macroSource          = RegexSource
    "@{%date}[ T]@{%time}(?:@{%timezone}| UTC)?"
        , macroSamples :: [[Char]]
    macroSamples         = (([Char], UTCTime) -> [Char]) -> [([Char], UTCTime)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], UTCTime) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], UTCTime)]
    samples
        , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
        , macroTestResults :: [TestResult]
    macroTestResults    = []
        , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseDateTime"
        , macroDescription :: [Char]
    macroDescription     = [Char]
    "ISO-8601 format date and time + simple variants"
        }
      where
        samples :: [(String,UTCTime)]
        samples :: [([Char], UTCTime)]
    samples =
            [ [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31 23:37:22.525343 UTC" [Char]
    "2016-12-31 23:37:22.525343Z"
            , [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31 23:37:22.525343"     [Char]
    "2016-12-31 23:37:22.525343Z"
            , [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31 23:37:22"            [Char]
    "2016-12-31 23:37:22Z"
            , [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31T23:37:22+0100"       [Char]
    "2016-12-31 23:37:22+0100"
            , [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31T23:37:22-01:00"      [Char]
    "2016-12-31 23:37:22-0100"
            , [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31T23:37:22-23:59"      [Char]
    "2016-12-31 23:37:22-2359"
            , [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31T23:37:22Z"           [Char]
    "2016-12-31 23:37:22Z"
            ]
          where
            f :: String -> String -> (String,UTCTime)
            f :: [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    s [Char]
    r_s = ([Char]
    s,[Char] -> UTCTime
    forall a. Read a => [Char] -> a
    read [Char]
    r_s)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "2016-12-31 23:37:22.525343 EST"
            ]

    datetime_8601_macro :: RegexType
                        -> MacroEnv
                        -> PreludeMacro
                        -> Maybe MacroDescriptor
    datetime_8601_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    datetime_8601_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe UTCTime)
    -> [([Char], UTCTime)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe UTCTime
    forall a. Replace a => a -> Maybe UTCTime
    parseDateTime [([Char], UTCTime)]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "@{%date}T@{%time}@{%timezone}"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], UTCTime) -> [Char]) -> [([Char], UTCTime)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], UTCTime) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], UTCTime)]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseDateTime8601"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "YYYY-MM-DDTHH:MM:SS[.Q*](Z|[+-]HHMM) format date and time"
          }
      where
        samples :: [(String,UTCTime)]
        samples :: [([Char], UTCTime)]
    samples =
            [ [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31T23:37:22.343Z"      [Char]
    "2016-12-31 23:37:22.343Z"
            , [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31T23:37:22-0100"      [Char]
    "2016-12-31 23:37:22-0100"
            , [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "2016-12-31T23:37:22+23:59"     [Char]
    "2016-12-31 23:37:22+2359"
            ]
          where
            f :: String -> String -> (String,UTCTime)
            f :: [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    s [Char]
    r_s = ([Char]
    s,[Char] -> UTCTime
    forall a. Read a => [Char] -> a
    read [Char]
    r_s)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "2016-12-31 23:37:22.525343 EST"
            ]

    datetime_clf_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    datetime_clf_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    datetime_clf_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe UTCTime)
    -> [([Char], UTCTime)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe UTCTime
    forall a. Replace a => a -> Maybe UTCTime
    parseDateTimeCLF [([Char], UTCTime)]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    re
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], UTCTime) -> [Char]) -> [([Char], UTCTime)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], UTCTime) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], UTCTime)]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseDateTimeCLF"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "Common Log Format date+time: %d/%b/%Y:%H:%M:%S %z"
          }
      where
        samples :: [(String,UTCTime)]
        samples :: [([Char], UTCTime)]
    samples =
            [ [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "10/Oct/2000:13:55:36 -0700"  [Char]
    "2000-10-10 13:55:36-0700"
            , [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    "10/Oct/2000:13:55:36 +07:00" [Char]
    "2000-10-10 13:55:36+0700"
            ]
          where
            f :: String -> String -> (String,UTCTime)
            f :: [Char] -> [Char] -> ([Char], UTCTime)
    f [Char]
    s [Char]
    r_s = ([Char]
    s,[Char] -> UTCTime
    forall a. Read a => [Char] -> a
    read [Char]
    r_s)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "2016-12-31T23:37+0100"
            , [Char]
    "10/Oct/2000:13:55:36-0700"
            , [Char]
    "10/OCT/2000:13:55:36 -0700"
            , [Char]
    "10/Oct/2000:13:55 -0700"
            , [Char]
    "10/Oct/2000:13:55Z"
            ]

        re :: RegexSource
    re = [Char] -> RegexSource
    RegexSource ([Char] -> RegexSource) -> [Char] -> RegexSource
    forall a b. (a -> b) -> a -> b
    $ [[Char]] -> [Char]
    unwords
          [ [Char]
    "[0-9]{2}/@{%shortmonth}/[0-9]{4}:[0-9]{2}:[0-9]{2}:[0-9]{2}"
          , [Char]
    "[+-][0-9]{2}:?[0-9]{2}"
          ]

    shortmonth_macro :: RegexType
                     -> MacroEnv
                     -> PreludeMacro
                     -> Maybe MacroDescriptor
    shortmonth_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    shortmonth_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe Int)
    -> [([Char], Int)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe Int
    forall a. Replace a => a -> Maybe Int
    parseShortMonth [([Char], Int)]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = [Char] -> RegexSource
    bracketedRegexSource ([Char] -> RegexSource) -> [Char] -> RegexSource
    forall a b. (a -> b) -> a -> b
    $
                                    [Char] -> [[Char]] -> [Char]
    forall a. [a] -> [[a]] -> [a]
    intercalate [Char]
    "|" ([[Char]] -> [Char]) -> [[Char]] -> [Char]
    forall a b. (a -> b) -> a -> b
    $ (Text -> [Char]) -> [Text] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> [Char]
    T.unpack ([Text] -> [[Char]]) -> [Text] -> [[Char]]
    forall a b. (a -> b) -> a -> b
    $ Array Int Text -> [Text]
    forall i e. Array i e -> [e]
    elems Array Int Text
    shortMonthArray
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], Int) -> [Char]) -> [([Char], Int)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], Int) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], Int)]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseShortMonth"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "three letter month name: Jan-Dec"
          }
      where
        samples :: [(String,Int)]
        samples :: [([Char], Int)]
    samples =
            [ [Char] -> Int -> ([Char], Int)
    forall a b. a -> b -> (a, b)
    f [Char]
    "Jan"   Int
    1
            , [Char] -> Int -> ([Char], Int)
    forall a b. a -> b -> (a, b)
    f [Char]
    "Feb"   Int
    2
            , [Char] -> Int -> ([Char], Int)
    forall a b. a -> b -> (a, b)
    f [Char]
    "Dec"   Int
    12
            ]
          where
            f :: a -> b -> (a, b)
    f = (,)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "jan"
            , [Char]
    "DEC"
            , [Char]
    "January"
            , [Char]
    "01"
            , [Char]
    "1"
            ]

    address_ipv4_macros :: RegexType
                        -> MacroEnv
                        -> PreludeMacro
                        -> Maybe MacroDescriptor
    address_ipv4_macros :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    address_ipv4_macros RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe IPV4Address)
    -> [([Char], IPV4Address)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe IPV4Address
    forall a. Replace a => a -> Maybe IPV4Address
    parseIPv4Address [([Char], IPV4Address)]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], IPV4Address) -> [Char])
    -> [([Char], IPV4Address)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], IPV4Address) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], IPV4Address)]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseSeverity"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "an a.b.c.d IPv4 address"
          }
      where
        samples :: [(String,IPV4Address)]
        samples :: [([Char], IPV4Address)]
    samples =
            [ [Char] -> IPV4Address -> ([Char], IPV4Address)
    forall a b. a -> b -> (a, b)
    f [Char]
    "0.0.0.0"           (  Word8
    0,  Word8
    0,  Word8
    0,  Word8
    0)
            , [Char] -> IPV4Address -> ([Char], IPV4Address)
    forall a b. a -> b -> (a, b)
    f [Char]
    "123.45.6.78"       (Word8
    123, Word8
    45,  Word8
    6, Word8
    78)
            , [Char] -> IPV4Address -> ([Char], IPV4Address)
    forall a b. a -> b -> (a, b)
    f [Char]
    "9.9.9.9"           (  Word8
    9,  Word8
    9,  Word8
    9,  Word8
    9)
            , [Char] -> IPV4Address -> ([Char], IPV4Address)
    forall a b. a -> b -> (a, b)
    f [Char]
    "255.255.255.255"   (Word8
    255,Word8
    255,Word8
    255,Word8
    255)
            ]
          where
            f :: a -> b -> (a, b)
    f = (,)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "foo"
            , [Char]
    "1234.0.0.0"
            , [Char]
    "1.2.3"
            , [Char]
    "1.2.3."
            , [Char]
    "1.2..4"
            , [Char]
    "www.example.com"
            , [Char]
    "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
            ]

    syslog_severity_macro :: RegexType
                          -> MacroEnv
                          -> PreludeMacro
                          -> Maybe MacroDescriptor
    syslog_severity_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    syslog_severity_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe Severity)
    -> [([Char], Severity)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe Severity
    forall a. Replace a => a -> Maybe Severity
    parseSeverity [([Char], Severity)]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    re
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], Severity) -> [Char]) -> [([Char], Severity)] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], Severity) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], Severity)]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = FunctionID -> Maybe FunctionID
    forall a. a -> Maybe a
    Just FunctionID
    "parseSeverity"
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "syslog severity keyword (debug-emerg)"
          }
      where
        samples :: [(String,Severity)]
        samples :: [([Char], Severity)]
    samples =
            [ [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "emerg"     Severity
    Emerg
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "panic"     Severity
    Emerg
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "alert"     Severity
    Alert
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "crit"      Severity
    Crit
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "err"       Severity
    Err
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "error"     Severity
    Err
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "warn"      Severity
    Warning
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "warning"   Severity
    Warning
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "notice"    Severity
    Notice
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "info"      Severity
    Info
            , [Char] -> Severity -> ([Char], Severity)
    forall a b. a -> b -> (a, b)
    f [Char]
    "debug"     Severity
    Debug
            ]
          where
            f :: a -> b -> (a, b)
    f = (,)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "Emergency"
            , [Char]
    "ALERT"
            ]

        re :: RegexSource
    re = if RegexType -> Bool
    isPCRE RegexType
    rty
          then RegexSource
    re_pcre
          else RegexSource
    re_tdfa

        re_tdfa :: RegexSource
    re_tdfa = [Char] -> RegexSource
    bracketedRegexSource ([Char] -> RegexSource) -> [Char] -> RegexSource
    forall a b. (a -> b) -> a -> b
    $
              [Char] -> [[Char]] -> [Char]
    forall a. [a] -> [[a]] -> [a]
    intercalate [Char]
    "|" ([[Char]] -> [Char]) -> [[Char]] -> [Char]
    forall a b. (a -> b) -> a -> b
    $
                [ Text -> [Char]
    T.unpack Text
    kw
                  | (Text
    kw0,[Text]
    kws) <- (Severity -> (Text, [Text])) -> [Severity] -> [(Text, [Text])]
    forall a b. (a -> b) -> [a] -> [b]
    map Severity -> (Text, [Text])
    severityKeywords [Severity
    forall a. Bounded a => a
    minBound..Severity
    forall a. Bounded a => a
    maxBound]
                  , Text
    kw <- Text
    kw0Text -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    kws
                  ]

        re_pcre :: RegexSource
    re_pcre = [Char] -> RegexSource
    bracketedRegexSource ([Char] -> RegexSource) -> [Char] -> RegexSource
    forall a b. (a -> b) -> a -> b
    $
              [Char] -> [[Char]] -> [Char]
    forall a. [a] -> [[a]] -> [a]
    intercalate [Char]
    "|" ([[Char]] -> [Char]) -> [[Char]] -> [Char]
    forall a b. (a -> b) -> a -> b
    $
                [ Text -> [Char]
    T.unpack Text
    kw
                  | (Text
    kw0,[Text]
    kws) <- (Severity -> (Text, [Text])) -> [Severity] -> [(Text, [Text])]
    forall a b. (a -> b) -> [a] -> [b]
    map Severity -> (Text, [Text])
    severityKeywords ([Severity] -> [(Text, [Text])]) -> [Severity] -> [(Text, [Text])]
    forall a b. (a -> b) -> a -> b
    $
                                      (Severity -> Bool) -> [Severity] -> [Severity]
    forall a. (a -> Bool) -> [a] -> [a]
    filter (Severity -> Severity -> Bool
    forall a. Eq a => a -> a -> Bool
    /=Severity
    Err) [Severity
    forall a. Bounded a => a
    minBound..Severity
    forall a. Bounded a => a
    maxBound]
                  , Text
    kw <- Text
    kw0Text -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    kws
                  ] [[Char]] -> [[Char]] -> [[Char]]
    forall a. [a] -> [a] -> [a]
    ++ [[Char]
    "err(?:or)?"]

    email_simple_macro :: RegexType
                       -> MacroEnv
                       -> PreludeMacro
                       -> Maybe MacroDescriptor
    email_simple_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    email_simple_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe [Char])
    -> [([Char], [Char])]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe [Char]
    forall a. a -> Maybe a
    Just [([Char], [Char])]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "[a-zA-Z0-9%_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9.-]+"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], [Char]) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], [Char])]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = Maybe FunctionID
    forall a. Maybe a
    Nothing
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "an email address"
          }
      where
        samples :: [(String,String)]
        samples :: [([Char], [Char])]
    samples =
            [ [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "user-name%foo.bar.com@an-example.com"
            ]
          where
            f :: b -> (b, b)
    f b
    s = (b
    s,b
    s)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "not-an-email-address"
            , [Char]
    "@not-an-email-address"
            ]
    -- | see https://mathiasbynens.be/demo/url-regex
    -- (based on @stephenhay URL)
    url_macro :: RegexType
              -> MacroEnv
              -> PreludeMacro
              -> Maybe MacroDescriptor
    url_macro :: RegexType -> MacroEnv -> PreludeMacro -> Maybe MacroDescriptor
    url_macro RegexType
    rty MacroEnv
    env PreludeMacro
    pm =
      MacroDescriptor -> Maybe MacroDescriptor
    forall a. a -> Maybe a
    Just (MacroDescriptor -> Maybe MacroDescriptor)
    -> MacroDescriptor -> Maybe MacroDescriptor
    forall a b. (a -> b) -> a -> b
    $ RegexType
    -> ([Char] -> Maybe [Char])
    -> [([Char], [Char])]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe [Char]
    forall a. a -> Maybe a
    Just [([Char], [Char])]
    samples MacroEnv
    env PreludeMacro
    pm
        MacroDescriptor
          { macroSource :: RegexSource
    macroSource          = RegexSource
    "([hH][tT][tT][pP][sS]?|[fF][tT][pP])://[^[:space:]/$.?#].[^[:space:]]*"
          , macroSamples :: [[Char]]
    macroSamples         = (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Char], [Char]) -> [Char]
    forall a b. (a, b) -> a
    fst [([Char], [Char])]
    samples
          , macroCounterSamples :: [[Char]]
    macroCounterSamples = [[Char]]
    counter_samples
          , macroTestResults :: [TestResult]
    macroTestResults    = []
          , macroParser :: Maybe FunctionID
    macroParser          = Maybe FunctionID
    forall a. Maybe a
    Nothing
          , macroDescription :: [Char]
    macroDescription     = [Char]
    "a URL"
          }
      where
        samples :: [(String,String)]
        samples :: [([Char], [Char])]
    samples =
            [ [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "https://mathiasbynens.be/demo/url-regex"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "http://foo.com/blah_blah"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "http://foo.com/blah_blah/"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "http://foo.com/blah_blah_(wikipedia)"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "http://foo.com/blah_blah_(wikipedia)_(again)"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "http://www.example.com/wpstyle/?p=364"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "HTTPS://foo.bar/?q=Test%20URL-encoded%20stuff"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "HTTP://223.255.255.254"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "ftp://223.255.255.254"
            , [Char] -> ([Char], [Char])
    forall {b}. b -> (b, b)
    f [Char]
    "FTP://223.255.255.254"
            ]
          where
            f :: b -> (b, b)
    f b
    s = (b
    s,b
    s)

        counter_samples :: [[Char]]
    counter_samples =
            [ [Char]
    ""
            , [Char]
    "http://"
            , [Char]
    "http://."
            , [Char]
    "http://.."
            , [Char]
    "http://../"
            , [Char]
    "http://?"
            , [Char]
    "http://??"
            , [Char]
    "http://foo.bar?q=Spaces should be encoded"
            , [Char]
    "//"
            , [Char]
    "http://##/"
            , [Char]
    "http://##"
            , [Char]
    "http://##/"
            ]

    run_tests :: (Eq a,Show a)
              => RegexType
              -> (String->Maybe a)
              -> [(String,a)]
              -> MacroEnv
              -> PreludeMacro
              -> MacroDescriptor
              -> MacroDescriptor
    run_tests :: forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    run_tests RegexType
    rty [Char] -> Maybe a
    parser [([Char], a)]
    vector MacroEnv
    env =
      RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> MacroID
    -> MacroDescriptor
    -> MacroDescriptor
    forall a.
    (Eq a, Show a) =>
    RegexType
    -> ([Char] -> Maybe a)
    -> [([Char], a)]
    -> MacroEnv
    -> MacroID
    -> MacroDescriptor
    -> MacroDescriptor
    runTests RegexType
    rty [Char] -> Maybe a
    parser [([Char], a)]
    vector MacroEnv
    env (MacroID -> MacroDescriptor -> MacroDescriptor)
    -> (PreludeMacro -> MacroID)
    -> PreludeMacro
    -> MacroDescriptor
    -> MacroDescriptor
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PreludeMacro -> MacroID
    prelude_macro_id

    bracketedRegexSource :: String -> RegexSource
    bracketedRegexSource :: [Char] -> RegexSource
    bracketedRegexSource [Char]
    re_s = [Char] -> RegexSource
    RegexSource ([Char] -> RegexSource) -> [Char] -> RegexSource
    forall a b. (a -> b) -> a -> b
    $ [Char]
    "(?:" [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    re_s [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    ")"

    fix :: (a->a) -> a
    fix :: forall a. (a -> a) -> a
    fix a -> a
    f = a -> a
    f ((a -> a) -> a
    forall a. (a -> a) -> a
    fix a -> a
    f)