@@ -1,19 +1,10 @@
11module Data.Schematic.Verifier.Text where
22
33import Control.Monad
4−import Data.List
54import Data.Maybe
65import Data.Schematic
7−import Data.Schematic.Schema
86import Data.Schematic.Verifier.Common
9−import Data.Singletons
10−import Data.Singletons.Prelude
11−import Data.Singletons.TypeLits
12−import Data.Text (unpack)
13−import Data.Text (Text)
14−import Data.Text.Array (Array)
15−import GHC.Generics
16−import Text.Regex.TDFA
7+import Data.Text (Text, unpack)
178import Text.Regex.TDFA.Pattern
189import Text.Regex.TDFA.ReadRegex (parseRegex)
1910
@@ -62,12 +53,12 @@ minRegexLength p =
6253 case p of
6354 PEmpty -> 0
6455 PChar {..} -> 1
65− PAny {getPatternSet = PatternSet (Just cset) _ _ _} -> 1
66− PAnyNot {getPatternSet = PatternSet (Just cset) _ _ _} -> 1
67− PQuest p -> 0
68− PPlus p -> minRegexLength $ PBound 1 Nothing p
69− PStar _ p -> minRegexLength $ PBound 0 Nothing p
70− PBound low mhigh p -> low * minRegexLength p
56+ PAny {..} -> 1
57+ PAnyNot {..} -> 1
58+ PQuest _ -> 0
59+ PPlus sch -> minRegexLength $ PBound 1 Nothing sch
60+ PStar _ sch -> minRegexLength $ PBound 0 Nothing sch
61+ PBound low _ sch -> low * minRegexLength sch
7162 PConcat ps -> sum $ fmap minRegexLength ps
7263 POr xs -> minimum $ fmap minRegexLength xs
7364 PDot _ -> 1
@@ -86,7 +77,7 @@ maxRegexLength p =
8677 PQuest _ -> Just 0
8778 PPlus _ -> Nothing
8879 PStar _ _ -> Nothing
89− PBound low mhigh p -> (*) <$> mhigh <*> maxRegexLength p
80+ PBound _ mhigh sch -> (*) <$> mhigh <*> maxRegexLength sch
9081 PConcat ps -> sum <$> mapM maxRegexLength ps
9182 POr xs -> maximum <$> mapM maxRegexLength xs
9283 PDot _ -> Just 1