predicate-typed 0.6.2.0 → 0.6.2.1
raw patch · 6 files changed
+30/−29 lines, 6 files
Files
- predicate-typed.cabal +2/−2
- src/Predicate/Prelude.hs +1/−1
- src/Predicate/Refined1.hs +5/−5
- src/Predicate/Refined2.hs +5/−5
- src/Predicate/Refined3.hs +6/−6
- src/Predicate/Util.hs +11/−10
predicate-typed.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 19bf59cd87614fe3ec3d9b00eb00da00ba01f97272fd8de160851fd4f0f9d8f7+-- hash: 97e6093ee31d1133d96d8a48d583c2214c64f0c07e1888a89ae874ccde82f8ed name: predicate-typed-version: 0.6.2.0+version: 0.6.2.1 synopsis: Predicates, Refinement types and Dsl description: Please see the README on GitHub at <https://github.com/gbwey/predicate-typed#readme> category: Data
src/Predicate/Prelude.hs view
@@ -8654,7 +8654,7 @@ Nothing -> mkNode opts (FailT (msg0 <> " must run in IO")) [msg0 <> " must run in IO"] [] Just v -> mkNode opts (PresentT v) [msg0 <> show0 opts " " v] [] -data FHandle s = FStdout | FStderr | FOther s WFMode deriving Show +data FHandle s = FStdout | FStderr | FOther !s !WFMode deriving Show class GetFHandle (x :: FHandle Symbol) where getFHandle :: FHandle String instance GetFHandle 'FStdout where getFHandle = FStdout
src/Predicate/Refined1.hs view
@@ -619,11 +619,11 @@ -- | An ADT that summarises the results of evaluating Refined1 representing all possible states data RResults1 a b = - RF String (Tree PE) -- Left e - | RTF a (Tree PE) String (Tree PE) -- Right a + Left e - | RTFalse a (Tree PE) (Tree PE) -- Right a + Right False - | RTTrueF a (Tree PE) (Tree PE) String (Tree PE) -- Right a + Right True + Left e - | RTTrueT a (Tree PE) (Tree PE) b (Tree PE) -- Right a + Right True + Right b + RF !String !(Tree PE) -- Left e + | RTF !a !(Tree PE) !String !(Tree PE) -- Right a + Left e + | RTFalse !a (Tree PE) !(Tree PE) -- Right a + Right False + | RTTrueF !a (Tree PE) !(Tree PE) !String !(Tree PE) -- Right a + Right True + Left e + | RTTrueT !a (Tree PE) !(Tree PE) !b !(Tree PE) -- Right a + Right True + Right b deriving Show -- | same as 'prtEval1P' but runs in IO
src/Predicate/Refined2.hs view
@@ -135,7 +135,7 @@ -- >>> prtEval2 @(MkDay' (Fst Id) (Snd Id) (Thd Id) >> 'Just Id) @(Guard "expected a Sunday" (Thd Id == 7) >> 'True) oz (2019,10,12) -- Left Step 2. Failed Boolean Check(op) | expected a Sunday -- -data Refined2 ip op i = Refined2 { r2In :: !(PP ip i), r2Out :: i } +data Refined2 ip op i = Refined2 { r2In :: !(PP ip i), r2Out :: !i } type role Refined2 nominal nominal nominal @@ -440,10 +440,10 @@ -- | An ADT that summarises the results of evaluating Refined2 representing all possible states data RResults2 a = - RF String (Tree PE) -- fails initial conversion - | RTF a (Tree PE) String (Tree PE) -- op fails - | RTFalse a (Tree PE) (Tree PE) -- op false - | RTTrue a (Tree PE) (Tree PE) -- op true + RF !String !(Tree PE) -- fails initial conversion + | RTF !a !(Tree PE) !String !(Tree PE) -- op fails + | RTFalse !a !(Tree PE) !(Tree PE) -- op false + | RTTrue !a !(Tree PE) !(Tree PE) -- op true deriving Show -- | same as 'prtEval2P' but runs in IO
src/Predicate/Refined3.hs view
@@ -176,7 +176,7 @@ -- >>> prtEval3P (Proxy @(T4 _)) oz (2019,10,13) -- Right (Refined3 {r3In = (2019-10-13,41,7), r3Out = (2019,10,13)}) -- -data Refined3 ip op fmt i = Refined3 { r3In :: !(PP ip i), r3Out :: PP fmt (PP ip i) } +data Refined3 ip op fmt i = Refined3 { r3In :: !(PP ip i), r3Out :: !(PP fmt (PP ip i)) } type role Refined3 nominal nominal nominal nominal @@ -611,11 +611,11 @@ -- | An ADT that summarises the results of evaluating Refined3 representing all possible states data RResults3 a b = - RF String (Tree PE) -- Left e - | RTF a (Tree PE) String (Tree PE) -- Right a + Left e - | RTFalse a (Tree PE) (Tree PE) -- Right a + Right False - | RTTrueF a (Tree PE) (Tree PE) String (Tree PE) -- Right a + Right True + Left e - | RTTrueT a (Tree PE) (Tree PE) b (Tree PE) -- Right a + Right True + Right b + RF !String !(Tree PE) -- Left e + | RTF !a !(Tree PE) !String !(Tree PE) -- Right a + Left e + | RTFalse !a !(Tree PE) !(Tree PE) -- Right a + Right False + | RTTrueF !a !(Tree PE) !(Tree PE) !String !(Tree PE) -- Right a + Right True + Left e + | RTTrueT !a !(Tree PE) !(Tree PE) !b !(Tree PE) -- Right a + Right True + Right b deriving Show -- | same as 'prtEval3P' but runs in IO
src/Predicate/Util.hs view
@@ -194,9 +194,8 @@ import GHC.Exts (Constraint) import qualified Text.Regex.PCRE.Heavy as RH import qualified Text.Regex.PCRE.Light as RL -import qualified Data.ByteString.Char8 as B8 import qualified Data.Text as T -import Data.ByteString (ByteString) +import qualified Data.Text.Encoding as TE import GHC.Word (Word8) import Data.Sequence (Seq) import Control.Applicative (ZipList) @@ -212,6 +211,7 @@ import qualified Text.Read.Lex as L import Text.ParserCombinators.ReadPrec import qualified GHC.Read as GR +import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy.Char8 as BL8 import qualified Data.ByteString.Char8 as BS8 import GHC.Stack @@ -275,15 +275,15 @@ -- | contains the untyped result from evaluating the expression tree data BoolP = - FailP String -- ^ fails the entire evaluation + FailP !String -- ^ fails the entire evaluation | FalseP -- ^ False predicate | TrueP -- ^ True predicate | PresentP -- ^ Any value deriving (Show, Eq) -- | represents the untyped evaluation tree for final display -data PE = PE { _pBool :: BoolP -- ^ holds the result of running the predicate - , _pStrings :: [String] -- ^ optional strings to include in the results +data PE = PE { _pBool :: !BoolP -- ^ holds the result of running the predicate + , _pStrings :: ![String] -- ^ optional strings to include in the results } deriving Show pBool :: Lens' PE BoolP @@ -326,7 +326,7 @@ fromTT (TT bt ss tt) = Node (PE (bt ^. boolT2P) ss) tt -- | a monomorphic container of trees -data Holder = forall w . Holder (TT w) +data Holder = forall w . Holder !(TT w) -- | converts a typed tree into an untyped one fromTTH :: Holder -> Tree PE @@ -600,7 +600,7 @@ | otherwise = let rs = getROpts @rs mm = nm <> " " <> show rs - in flip left (RH.compileM (B8.pack s) rs) + in flip left (RH.compileM (TE.encodeUtf8 (T.pack s)) rs) $ \e -> mkNode opts (FailT "Regex failed to compile") [mm <> " compile failed with regex msg[" <> e <> "]"] hhs -- | extract the regex options from the type level list @@ -640,9 +640,9 @@ -- These parallel the RegexReplacement (not exported) class in "Text.Regex.PCRE.Heavy" but have overlappable instances which is problematic for this code so I use 'RReplace' data RReplace = RReplace !String - | RReplace1 (String -> [String] -> String) - | RReplace2 (String -> String) - | RReplace3 ([String] -> String) + | RReplace1 !(String -> [String] -> String) + | RReplace2 !(String -> String) + | RReplace3 !([String] -> String) instance Show RReplace where show = \case @@ -738,6 +738,7 @@ (~>) :: Bool -> Bool -> Bool p ~> q = not p || q +infixr 1 ~> -- | type level Between type family ZwischenT (a :: Nat) (b :: Nat) (v :: Nat) :: Constraint where