Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utility methods for Predicate / methods for displaying the evaluation tree
Synopsis
- data TT a = TT {}
- tBool :: Lens (TT a) (TT b) (BoolT a) (BoolT b)
- tStrings :: Lens' (TT a) [String]
- tForest :: Lens' (TT a) (Forest PE)
- fixBoolT :: TT Bool -> TT Bool
- topMessage :: TT a -> String
- topMessage' :: TT a -> String
- hasNoTree :: POpts -> Bool
- data BoolT a where
- _FailT :: Prism' (BoolT a) String
- _PresentT :: Prism' (BoolT a) a
- _FalseT :: Prism' (BoolT Bool) ()
- _TrueT :: Prism' (BoolT Bool) ()
- boolT2P :: Lens' (BoolT a) BoolP
- data BoolP
- data PE = PE BoolP [String]
- pStrings :: Lens' PE [String]
- pBool :: Lens' PE BoolP
- mkNode :: POpts -> BoolT a -> [String] -> [Holder] -> TT a
- mkNodeB :: POpts -> Bool -> [String] -> [Holder] -> TT Bool
- mkNodeSkipP :: Tree PE
- getValAndPE :: TT a -> (Either String a, Tree PE)
- getValLRFromTT :: TT a -> Either String a
- fromTT :: TT a -> Tree PE
- getValueLR :: POpts -> String -> TT a -> [Holder] -> Either (TT x) a
- getValueLRHide :: POpts -> String -> TT a -> [Holder] -> Either (TT x) a
- fixLite :: forall a. Show a => POpts -> a -> Tree PE -> String
- fixit :: ((Int, x), TT a) -> TT a
- prefixMsg :: String -> TT a -> TT a
- splitAndAlign :: Show x => POpts -> [String] -> [((Int, x), TT a)] -> Either (TT w) [(a, (Int, x), TT a)]
- data POpts = POpts {}
- data ODebug
- = OZero
- | OLite
- | OSubNormal
- | ONormal
- | OVerbose
- defOpts :: POpts
- oz :: POpts
- ol :: POpts
- olc :: POpts
- o0 :: POpts
- o2 :: POpts
- o2n :: POpts
- o3 :: POpts
- ou :: POpts
- ou3 :: POpts
- oun :: POpts
- setw :: Int -> POpts -> POpts
- setu :: POpts -> POpts
- setc :: (String, PColor) -> POpts -> POpts
- color0 :: (String, PColor)
- color1 :: (String, PColor)
- color2 :: (String, PColor)
- color3 :: (String, PColor)
- color4 :: (String, PColor)
- colorMe :: POpts -> BoolP -> String -> String
- zero :: POpts -> POpts
- lite :: POpts -> POpts
- subnormal :: POpts -> POpts
- normal :: POpts -> POpts
- verbose :: POpts -> POpts
- isVerbose :: POpts -> Bool
- ansi :: POpts -> POpts
- unicode :: POpts -> POpts
- showBoolP :: POpts -> BoolP -> String
- show01 :: (Show a1, Show a2) => POpts -> String -> a1 -> a2 -> String
- lit01 :: Show a1 => POpts -> String -> a1 -> String -> String
- show01' :: (Show a1, Show a2) => POpts -> String -> a1 -> String -> a2 -> String
- lit01' :: Show a1 => POpts -> String -> a1 -> String -> String -> String
- showLit0 :: POpts -> String -> String -> String
- showLit1 :: POpts -> String -> String -> String
- show0 :: Show a => POpts -> String -> a -> String
- show3 :: Show a => POpts -> String -> a -> String
- show1 :: Show a => POpts -> String -> a -> String
- showL :: Show a => Int -> a -> String
- litL :: Int -> String -> String
- data ROpt
- compileRegex :: forall rs a. GetROpts rs => POpts -> String -> String -> [Holder] -> Either (TT a) Regex
- class GetROpts (os :: [ROpt]) where
- getROpts :: [PCREOption]
- data RReplace
- type family ZwischenT (a :: Nat) (b :: Nat) (v :: Nat) :: Constraint where ...
- type family FailWhenT (b :: Bool) (msg :: ErrorMessage) :: Constraint where ...
- type family FailUnlessT (b :: Bool) (msg :: ErrorMessage) :: Constraint where ...
- type family AndT (b :: Bool) (b1 :: Bool) :: Bool where ...
- type family OrT (b :: Bool) (b1 :: Bool) :: Bool where ...
- type family NotT (b :: Bool) :: Bool where ...
- type family RepeatT (n :: Nat) (p :: k) :: [k] where ...
- type family IntersperseT (s :: Symbol) (xs :: [Symbol]) :: Symbol where ...
- type family LenT (xs :: [k]) :: Nat where ...
- class InductTupleC x where
- type InductTupleP x
- inductTupleC :: x -> InductTupleP x
- class InductListC (n :: Nat) a where
- type InductListP n a
- inductListC :: [a] -> InductListP n a
- type family FlipT (d :: k1 -> k -> k2) (p :: k) (q :: k1) :: k2 where ...
- type family IfT (b :: Bool) (t :: k) (f :: k) :: k where ...
- type family SumT (ns :: [Nat]) :: Nat where ...
- type family MapT (f :: k -> k1) (xs :: [k]) :: [k1] where ...
- type family ConsT s where ...
- type family (p :: k -> k1) %% (q :: k) :: k1 where ...
- type family (p :: k) %& (q :: k -> k1) :: k1 where ...
- type (<%>) s t = AppendSymbol s t
- nat :: forall n a. (KnownNat n, Num a) => a
- symb :: forall s. KnownSymbol s => String
- class GetNats as where
- class GetSymbs ns where
- class GetLen xs where
- showThese :: These a b -> String
- class GetThese th where
- class GetOrdering (cmp :: Ordering) where
- class GetBool (a :: Bool) where
- data OrderingP
- class GetOrd (k :: OrderingP) where
- prtTTIO :: POpts -> IO (TT a) -> IO ()
- prtTT :: POpts -> Identity (TT a) -> IO ()
- prtTree :: POpts -> Tree PE -> IO ()
- prtTreePure :: POpts -> Tree PE -> String
- prettyRational :: Rational -> String
- (~>) :: Bool -> Bool -> Bool
- data Holder
- hh :: TT w -> Holder
- showT :: forall (t :: Type). Typeable t => String
- prettyOrd :: Ordering -> String
- removeAnsi :: Show a => Either String a -> IO ()
- class Monad m => MonadEval m where
- errorInProgram :: String -> x
- readField :: String -> ReadPrec a -> ReadPrec a
TT
represents the evaluation tree for predicates
TT | the child nodes |
Instances
Foldable TT Source # | |
Defined in Predicate.Util fold :: Monoid m => TT m -> m # foldMap :: Monoid m => (a -> m) -> TT a -> m # foldr :: (a -> b -> b) -> b -> TT a -> b # foldr' :: (a -> b -> b) -> b -> TT a -> b # foldl :: (b -> a -> b) -> b -> TT a -> b # foldl' :: (b -> a -> b) -> b -> TT a -> b # foldr1 :: (a -> a -> a) -> TT a -> a # foldl1 :: (a -> a -> a) -> TT a -> a # elem :: Eq a => a -> TT a -> Bool # maximum :: Ord a => TT a -> a # | |
Show a => Show (TT a) Source # | |
topMessage :: TT a -> String Source #
topMessage' :: TT a -> String Source #
BoolT
contains the typed result from evaluating the expression tree
Instances
Foldable BoolT Source # | |
Defined in Predicate.Util fold :: Monoid m => BoolT m -> m # foldMap :: Monoid m => (a -> m) -> BoolT a -> m # foldr :: (a -> b -> b) -> b -> BoolT a -> b # foldr' :: (a -> b -> b) -> b -> BoolT a -> b # foldl :: (b -> a -> b) -> b -> BoolT a -> b # foldl' :: (b -> a -> b) -> b -> BoolT a -> b # foldr1 :: (a -> a -> a) -> BoolT a -> a # foldl1 :: (a -> a -> a) -> BoolT a -> a # elem :: Eq a => a -> BoolT a -> Bool # maximum :: Ord a => BoolT a -> a # minimum :: Ord a => BoolT a -> a # | |
Eq a => Eq (BoolT a) Source # | |
Show a => Show (BoolT a) Source # | |
BoolP
contains the untyped result from evaluating the expression tree
represents the untyped evaluation tree for final display
create tree functions
mkNode :: POpts -> BoolT a -> [String] -> [Holder] -> TT a Source #
creates a Node for the evaluation tree
mkNodeB :: POpts -> Bool -> [String] -> [Holder] -> TT Bool Source #
creates a Boolean node for a predicate type
mkNodeSkipP :: Tree PE Source #
tree manipulation
getValueLR :: POpts -> String -> TT a -> [Holder] -> Either (TT x) a Source #
see getValueLRImpl
: add more detail to the tree if there are errors
getValueLRHide :: POpts -> String -> TT a -> [Holder] -> Either (TT x) a Source #
see getValueLRImpl
: add less detail to the tree if there are errors
splitAndAlign :: Show x => POpts -> [String] -> [((Int, x), TT a)] -> Either (TT w) [(a, (Int, x), TT a)] Source #
extract values from the trees or if there are errors returned a tree with added context
display options
customizable options
OZero | one line summary used mainly for testing |
OLite | one line summary with additional context from the head of the evaluation tree |
OSubNormal | outputs the evaluation tree but skips noisy subtrees |
ONormal | outputs the evaluation tree but skips noisy subtrees |
OVerbose | outputs the entire evaluation tree |
displays the detailed evaluation tree using unicode and colors. (o2
works better on Windows)
color0 :: (String, PColor) Source #
no colors are displayed
color palettes
italics dont work but underline does
color1 :: (String, PColor) Source #
default color palette
color palettes
italics dont work but underline does
colorMe :: POpts -> BoolP -> String -> String Source #
colors the result of the predicate based on the current color palette
formatting functions
showLit1 :: POpts -> String -> String -> String Source #
more restrictive: only display data at debug level 1 or less
regular expressions
Regex options for Rescan Resplit Re etc
Anchored | Force pattern anchoring |
Auto_callout | Compile automatic callouts | Bsr_anycrlf -- R matches only CR, LF, or CrlF | Bsr_unicode -- ^ R matches all Unicode line endings |
Caseless | Do caseless matching |
Dollar_endonly | dollar not to match newline at end |
Dotall | matches anything including NL |
Dupnames | Allow duplicate names for subpatterns |
Extended | Ignore whitespace and # comments |
Extra | PCRE extra features (not much use currently) |
Firstline | Force matching to be before newline |
Multiline | caret and dollar match newlines within data | Newline_any -- ^ Recognize any Unicode newline sequence | Newline_anycrlf -- ^ Recognize CR, LF, and CrlF as newline sequences |
Newline_cr | Set CR as the newline sequence |
Newline_crlf | Set CrlF as the newline sequence |
Newline_lf | Set LF as the newline sequence |
No_auto_capture | Disable numbered capturing parentheses (named ones available) |
Ungreedy | Invert greediness of quantifiers |
Utf8 | Run in UTF--8 mode |
No_utf8_check | Do not check the pattern for UTF-8 validity |
Instances
Bounded ROpt Source # | |
Enum ROpt Source # | |
Eq ROpt Source # | |
Ord ROpt Source # | |
Show ROpt Source # | |
GetROpts ([] :: [ROpt]) Source # | |
Defined in Predicate.Util getROpts :: [PCREOption] Source # | |
(GetROpt r, GetROpts rs) => GetROpts (r ': rs) Source # | |
Defined in Predicate.Util getROpts :: [PCREOption] Source # |
compileRegex :: forall rs a. GetROpts rs => POpts -> String -> String -> [Holder] -> Either (TT a) Regex Source #
compile a regex using the type level symbol
class GetROpts (os :: [ROpt]) where Source #
extract the regex options from the type level list
getROpts :: [PCREOption] Source #
Instances
GetROpts ([] :: [ROpt]) Source # | |
Defined in Predicate.Util getROpts :: [PCREOption] Source # | |
(GetROpt r, GetROpts rs) => GetROpts (r ': rs) Source # | |
Defined in Predicate.Util getROpts :: [PCREOption] Source # |
used by ReplaceImpl
and sub
and gsub
to allow more flexible replacement
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
useful type families
type family ZwischenT (a :: Nat) (b :: Nat) (v :: Nat) :: Constraint where ... Source #
type level Between
type family FailWhenT (b :: Bool) (msg :: ErrorMessage) :: Constraint where ... Source #
helper method to fail with a msg when True
type family FailUnlessT (b :: Bool) (msg :: ErrorMessage) :: Constraint where ... Source #
helper method to fail with msg when False
FailUnlessT True _ = () | |
FailUnlessT False e = TypeError e |
type family IntersperseT (s :: Symbol) (xs :: [Symbol]) :: Symbol where ... Source #
IntersperseT s '[] = "" | |
IntersperseT s '[x] = x | |
IntersperseT s (x ': (y ': xs)) = x <%> (s <%> IntersperseT s (y ': xs)) |
class InductTupleC x where Source #
takes a flat n-tuple and creates a reversed inductive tuple. see PrintT
>>>
inductTupleC (123,'x',False,"abc")
("abc",(False,('x',(123,()))))
>>>
inductTupleC (123,'x')
('x',(123,()))
type InductTupleP x Source #
inductTupleC :: x -> InductTupleP x Source #
Instances
(TypeError (Text "InductTupleC: inductive tuple cannot be empty") :: Constraint) => InductTupleC () Source # | |
Defined in Predicate.Util type InductTupleP () :: Type Source # inductTupleC :: () -> InductTupleP () Source # | |
InductTupleC (a, b) Source # | |
Defined in Predicate.Util type InductTupleP (a, b) :: Type Source # inductTupleC :: (a, b) -> InductTupleP (a, b) Source # | |
InductTupleC (a, b, c) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c) :: Type Source # inductTupleC :: (a, b, c) -> InductTupleP (a, b, c) Source # | |
InductTupleC (a, b, c, d) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c, d) :: Type Source # inductTupleC :: (a, b, c, d) -> InductTupleP (a, b, c, d) Source # | |
InductTupleC (a, b, c, d, e) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c, d, e) :: Type Source # inductTupleC :: (a, b, c, d, e) -> InductTupleP (a, b, c, d, e) Source # | |
InductTupleC (a, b, c, d, e, f) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c, d, e, f) :: Type Source # inductTupleC :: (a, b, c, d, e, f) -> InductTupleP (a, b, c, d, e, f) Source # | |
InductTupleC (a, b, c, d, e, f, g) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c, d, e, f, g) :: Type Source # inductTupleC :: (a, b, c, d, e, f, g) -> InductTupleP (a, b, c, d, e, f, g) Source # | |
InductTupleC (a, b, c, d, e, f, g, h) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c, d, e, f, g, h) :: Type Source # inductTupleC :: (a, b, c, d, e, f, g, h) -> InductTupleP (a, b, c, d, e, f, g, h) Source # | |
InductTupleC (a, b, c, d, e, f, g, h, i) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c, d, e, f, g, h, i) :: Type Source # inductTupleC :: (a, b, c, d, e, f, g, h, i) -> InductTupleP (a, b, c, d, e, f, g, h, i) Source # | |
InductTupleC (a, b, c, d, e, f, g, h, i, j) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c, d, e, f, g, h, i, j) :: Type Source # inductTupleC :: (a, b, c, d, e, f, g, h, i, j) -> InductTupleP (a, b, c, d, e, f, g, h, i, j) Source # | |
InductTupleC (a, b, c, d, e, f, g, h, i, j, k) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c, d, e, f, g, h, i, j, k) :: Type Source # inductTupleC :: (a, b, c, d, e, f, g, h, i, j, k) -> InductTupleP (a, b, c, d, e, f, g, h, i, j, k) Source # | |
InductTupleC (a, b, c, d, e, f, g, h, i, j, k, l) Source # | |
Defined in Predicate.Util type InductTupleP (a, b, c, d, e, f, g, h, i, j, k, l) :: Type Source # inductTupleC :: (a, b, c, d, e, f, g, h, i, j, k, l) -> InductTupleP (a, b, c, d, e, f, g, h, i, j, k, l) Source # |
class InductListC (n :: Nat) a where Source #
takes a list and converts to a reversed inductive tuple. see PrintL
>>>
inductListC @4 [10,12,13,1]
(1,(13,(12,(10,()))))
>>>
inductListC @2 ["ab","cc"]
("cc",("ab",()))
type InductListP n a Source #
inductListC :: [a] -> InductListP n a Source #
Instances
type family FlipT (d :: k1 -> k -> k2) (p :: k) (q :: k1) :: k2 where ... Source #
FlipT d p q = d q p |
type (<%>) s t = AppendSymbol s t infixr 6 Source #
extract values from the type level
symb :: forall s. KnownSymbol s => String Source #
gets the Symbol from the typelevel
>>>
symb @"abc"
"abc"
class GetNats as where Source #
get a list of Nats from the typelevel
>>>
getNats @'[10,12,1]
[10,12,1]
class GetSymbs ns where Source #
get a list of Symbols from the typelevel
>>>
getSymbs @'["abc","def","g"]
["abc","def","g"]
class GetLen xs where Source #
get the length of a typelevel container
>>>
getLen @'["abc","def","g"]
3
>>>
getLen @'[]
0
>>>
getLen @(9 ':| '[1,2,3])
4
>>>
getLen @('These 9 "Asfs")
1
>>>
getLen @('This 1)
0
Instances
GetLen ([] :: [k]) Source # | |
Defined in Predicate.Util | |
GetLen (Nothing :: Maybe a) Source # | |
Defined in Predicate.Util | |
GetLen (Just a2 :: Maybe a1) Source # | |
Defined in Predicate.Util | |
GetLen xs => GetLen (x ': xs :: [a]) Source # | |
Defined in Predicate.Util | |
GetLen xs => GetLen (x :| xs :: NonEmpty a) Source # | |
Defined in Predicate.Util | |
GetLen (Right a2 :: Either a1 b) Source # | |
Defined in Predicate.Util | |
GetLen (Left a2 :: Either a1 b) Source # | |
Defined in Predicate.Util | |
GetLen (That a2 :: These a1 b) Source # | |
Defined in Predicate.Util | |
GetLen (This a2 :: These a1 b) Source # | |
Defined in Predicate.Util | |
GetLen (These a2 b2 :: These a1 b1) Source # | |
Defined in Predicate.Util |
class GetOrdering (cmp :: Ordering) where Source #
get ordering from the typelevel
Instances
GetOrdering LT Source # | |
Defined in Predicate.Util | |
GetOrdering EQ Source # | |
Defined in Predicate.Util | |
GetOrdering GT Source # | |
Defined in Predicate.Util |
Instances
Bounded OrderingP Source # | |
Enum OrderingP Source # | |
Defined in Predicate.Util succ :: OrderingP -> OrderingP # pred :: OrderingP -> OrderingP # fromEnum :: OrderingP -> Int # enumFrom :: OrderingP -> [OrderingP] # enumFromThen :: OrderingP -> OrderingP -> [OrderingP] # enumFromTo :: OrderingP -> OrderingP -> [OrderingP] # enumFromThenTo :: OrderingP -> OrderingP -> OrderingP -> [OrderingP] # | |
Eq OrderingP Source # | |
Show OrderingP Source # | |
printing methods
prettyRational :: Rational -> String Source #
boolean methods
(~>) :: Bool -> Bool -> Bool Source #
boolean implication
>>>
True ~> False
False
>>>
True ~> True
True
>>>
False ~> False
True
>>>
False ~> True
True
miscellaneous
removeAnsi :: Show a => Either String a -> IO () Source #
strip ansi characters from a string and print it (for doctests)
class Monad m => MonadEval m where Source #
a typeclass for choosing which monad to run in
runIO :: IO a -> m (Maybe a) Source #
catchit :: Exception e => a -> m (Either String a) Source #
catchitNF :: (Exception e, NFData a) => a -> m (Either String a) Source #
errorInProgram :: String -> x Source #