Safe Haskell | None |
---|---|
Language | Haskell2010 |
utility methods
Synopsis
- data Val a
- _Fail :: forall a. Prism' (Val a) String
- _Val :: forall a a. Prism (Val a) (Val a) a a
- _ValEither :: Iso (Val a) (Val b) (Either String a) (Either String b)
- data TT a
- ttVal :: Lens (TT a) (TT b) (Val a) (Val b)
- ttValBool :: a ~ Bool => Lens' (TT a) (Val Bool)
- ttString :: forall a. Lens' (TT a) String
- ttForest :: forall a. Lens' (TT a) (Forest PE)
- data PE = PE {}
- peValP :: Lens' PE ValP
- peString :: Lens' PE String
- data ValP
- _FailP :: Prism' ValP String
- _TrueP :: Prism' ValP ()
- _FalseP :: Prism' ValP ()
- _ValP :: Prism' ValP ()
- mkNode :: POpts -> Val a -> String -> [Tree PE] -> TT a
- mkNodeB :: POpts -> Bool -> String -> [Tree PE] -> TT Bool
- mkNodeCopy :: POpts -> TT a -> String -> [Tree PE] -> TT a
- getValAndPE :: TT a -> (Either String a, Tree PE)
- getValLRFromTT :: TT a -> Either String a
- getValueLR :: Inline -> POpts -> String -> TT a -> [Tree PE] -> Either (TT x) a
- data Inline
- prefixNumberToTT :: ((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)]
- verboseList :: POpts -> TT a -> [Tree PE]
- fixTTBool :: TT Bool -> TT Bool
- topMessage :: TT a -> String
- hasNoTree :: POpts -> Bool
- type POpts = HOpts Identity
- data Debug
- data Disp
- data Color
- isVerbose :: POpts -> Bool
- colorValBool :: POpts -> Val Bool -> String
- colorValP :: Long -> POpts -> ValP -> String
- data Long
- setOtherEffects :: POpts -> String -> String
- type Color1 = 'OColor "color1" 'Default 'Blue 'Default 'Red 'Black 'Cyan 'Black 'Yellow
- type Color2 = 'OColor "color2" 'Default 'Magenta 'Default 'Red 'Black 'White 'Black 'Yellow
- type Color3 = 'OColor "color3" 'Default 'Blue 'Red 'Default 'White 'Default 'Black 'Yellow
- type Color4 = 'OColor "color4" 'Default 'Red 'Red 'Default 'Green 'Default 'Black 'Yellow
- type Color5 = 'OColor "color5" 'Blue 'Default 'Red 'Default 'Cyan 'Default 'Yellow 'Default
- type Other1 = 'OOther 'Underline 'Yellow 'Default
- type Other2 = 'OOther 'Underline 'Default 'Default
- type OZ = 'OZ
- type OL = 'OL
- type OA = 'OA
- type OAB = 'OAB
- type OAN = 'OAN
- type OAV = 'OAV
- type OANV = 'OANV
- type OU = 'OU
- type OUB = 'OUB
- type OUN = 'OUN
- type OUV = 'OUV
- type OUNV = 'OUNV
- data HOpts f = HOpts {}
- data Opt
- = OEmpty
- | OWidth !Nat
- | OMsg !Symbol
- | ORecursion !Nat
- | ORecursionLarge !Nat
- | OLarge !Bool
- | OOther !Style !Color !Color
- | !Opt :# !Opt
- | OColor !Symbol !Color !Color !Color !Color !Color !Color !Color !Color
- | OColorOn
- | OColorOff
- | OAnsi
- | OUnicode
- | OZero
- | OLite
- | ONormal
- | OVerbose
- | OZ
- | OL
- | OA
- | OAB
- | OAN
- | OAV
- | OANV
- | OU
- | OUB
- | OUN
- | OUV
- | OUNV
- class OptC (k :: Opt)
- type family OptT (xs :: [Opt]) where ...
- getOpt :: forall o. OptC o => POpts
- zeroToLite :: POpts -> POpts
- defOpts :: POpts
- show3 :: (Show a1, Show a2) => POpts -> String -> a1 -> a2 -> String
- show3' :: (Show a1, Show a2) => POpts -> String -> a1 -> String -> a2 -> String
- lit3 :: Show a1 => POpts -> String -> a1 -> String -> String -> String
- litVerbose :: POpts -> String -> String -> String
- showVerbose :: Show a => POpts -> String -> a -> String
- showL :: Show a => POpts -> a -> String
- litL :: POpts -> String -> String
- litBL :: POpts -> ByteString -> String
- litBS :: POpts -> ByteString -> String
- joinStrings :: String -> String -> String
- prtTreePure :: POpts -> Tree PE -> String
- formatOMsg :: POpts -> String -> String
- prtTree :: Show x => POpts -> TT x -> String
- class Monad m => MonadEval m where
- hh :: TT a -> Tree PE
- chkSize :: Foldable t => POpts -> String -> t a -> [Tree PE] -> Either (TT x) (Int, [a])
- chkSize2 :: (Foldable t, Foldable u) => POpts -> String -> t a -> u b -> [Tree PE] -> Either (TT x) ((Int, [a]), (Int, [b]))
- badLength :: Int -> Int -> String
- getMaxRecursionValue :: POpts -> Int
- lengthGreaterThanOne :: [a] -> Bool
Val
contains the typed result from evaluating an expression
Instances
Monad Val Source # | |
Functor Val Source # | |
Applicative Val Source # | |
Foldable Val Source # | |
Defined in Predicate.Util fold :: Monoid m => Val m -> m # foldMap :: Monoid m => (a -> m) -> Val a -> m # foldMap' :: Monoid m => (a -> m) -> Val a -> m # foldr :: (a -> b -> b) -> b -> Val a -> b # foldr' :: (a -> b -> b) -> b -> Val a -> b # foldl :: (b -> a -> b) -> b -> Val a -> b # foldl' :: (b -> a -> b) -> b -> Val a -> b # foldr1 :: (a -> a -> a) -> Val a -> a # foldl1 :: (a -> a -> a) -> Val a -> a # elem :: Eq a => a -> Val a -> Bool # maximum :: Ord a => Val a -> a # | |
Traversable Val Source # | |
Eq a => Eq (Val a) Source # | |
Data a => Data (Val a) Source # | |
Defined in Predicate.Util gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Val a -> c (Val a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Val a) # dataTypeOf :: Val a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Val a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Val a)) # gmapT :: (forall b. Data b => b -> b) -> Val a -> Val a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r # gmapQ :: (forall d. Data d => d -> u) -> Val a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Val a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Val a -> m (Val a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Val a -> m (Val a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Val a -> m (Val a) # | |
Ord a => Ord (Val a) Source # | |
Read a => Read (Val a) Source # | |
Show a => Show (Val a) Source # | |
Generic (Val a) Source # | |
Semigroup (Val a) Source # | semigroup instance for
|
Monoid a => Monoid (Val a) Source # | monoid instance for
|
Generic1 Val Source # | |
type Rep (Val a) Source # | |
Defined in Predicate.Util type Rep (Val a) = D1 ('MetaData "Val" "Predicate.Util" "predicate-typed-0.7.4.5-JjMXzrXEzX77YMQbrq7lii" 'False) (C1 ('MetaCons "Fail" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)) :+: C1 ('MetaCons "Val" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a))) | |
type Rep1 Val Source # | |
Defined in Predicate.Util type Rep1 Val = D1 ('MetaData "Val" "Predicate.Util" "predicate-typed-0.7.4.5-JjMXzrXEzX77YMQbrq7lii" 'False) (C1 ('MetaCons "Fail" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)) :+: C1 ('MetaCons "Val" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) Par1)) |
_ValEither :: Iso (Val a) (Val b) (Either String a) (Either String b) Source #
iso for Val
>>>
Val 123 ^. _ValEither
Right 123
>>>
Val 123 & _ValEither %~ right' (show . succ)
Val "124"
>>>
Fail "abc" & _ValEither %~ ((<>"def") +++ (show . succ))
Fail "abcdef"
>>>
Right 1.2 & from _ValEither %~ fmap (show . (*10))
Right "12.0"
>>>
Val True ^. _ValEither
Right True
>>>
Fail "abc" ^. _ValEither
Left "abc"
>>>
Left "abc" ^. from _ValEither
Fail "abc"
>>>
_ValEither # Right False
Val False
>>>
[Just (Val 'x')] ^. mapping (mapping _ValEither)
[Just (Right 'x')]
>>>
Just (Fail "abcd") ^. mapping _ValEither
Just (Left "abcd")
TT typed tree
Read
instance for Val
>>>
reads @(Val Int) "Val 123"
[(Val 123,"")]
>>>
reads @(Val Bool) "Val False abc"
[(Val False," abc")]
>>>
reads @(Val Bool) "Fail \"some error message\""
[(Fail "some error message","")]
>>>
reads @(Val Double) "Fail \"some error message\""
[(Fail "some error message","")]
typed tree holding the results of evaluating a type level expression
Instances
Monad TT Source # | |
Functor TT Source # | |
Applicative TT Source # | |
Foldable TT Source # | |
Defined in Predicate.Util fold :: Monoid m => TT m -> m # foldMap :: Monoid m => (a -> m) -> TT a -> 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 # | |
Traversable TT Source # | |
Eq a => Eq (TT a) Source # | |
Data a => Data (TT a) Source # | |
Defined in Predicate.Util gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TT a -> c (TT a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (TT a) # dataTypeOf :: TT a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (TT a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (TT a)) # gmapT :: (forall b. Data b => b -> b) -> TT a -> TT a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TT a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TT a -> r # gmapQ :: (forall d. Data d => d -> u) -> TT a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TT a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TT a -> m (TT a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TT a -> m (TT a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TT a -> m (TT a) # | |
Read a => Read (TT a) Source # | |
Show a => Show (TT a) Source # | |
Generic (TT a) Source # | |
Semigroup (TT a) Source # | |
Monoid a => Monoid (TT a) Source # | |
Generic1 TT Source # | |
type Rep (TT a) Source # | |
Defined in Predicate.Util type Rep (TT a) = D1 ('MetaData "TT" "Predicate.Util" "predicate-typed-0.7.4.5-JjMXzrXEzX77YMQbrq7lii" 'False) (C1 ('MetaCons "TT" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_ttValP") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ValP) :*: S1 ('MetaSel ('Just "_ttVal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Val a))) :*: (S1 ('MetaSel ('Just "_ttString") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String) :*: S1 ('MetaSel ('Just "_ttForest") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Forest PE))))) | |
type Rep1 TT Source # | |
Defined in Predicate.Util type Rep1 TT = D1 ('MetaData "TT" "Predicate.Util" "predicate-typed-0.7.4.5-JjMXzrXEzX77YMQbrq7lii" 'False) (C1 ('MetaCons "TT" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_ttValP") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ValP) :*: S1 ('MetaSel ('Just "_ttVal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec1 Val)) :*: (S1 ('MetaSel ('Just "_ttString") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String) :*: S1 ('MetaSel ('Just "_ttForest") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Forest PE))))) |
ttVal :: Lens (TT a) (TT b) (Val a) (Val b) Source #
lens from TT
to Val
that also keeps ValP
in sync with Val
>>>
(TT FalseP (Val True) "xxx" [] & ttVal %~ id) == TT ValP (Val True) "xxx" []
True
>>>
(TT FalseP (Val 123) "xxx" [] & ttVal .~ Fail "aa") == TT (FailP "aa") (Fail "aa") "xxx" []
True
>>>
(TT (FailP "sdf") (Val 123) "xxx" [] & ttVal %~ fmap show) == TT ValP (Val "123") "xxx" []
True
ttValBool :: a ~ Bool => Lens' (TT a) (Val Bool) Source #
lens that keeps ValP
in sync with Val
for TT Bool
>>>
(TT ValP (Val True) "xxx" [] & ttValBool %~ \b -> fmap not b) == TT FalseP (Val False) "xxx" []
True
>>>
(TT ValP (Val True) "xxx" [] & ttValBool .~ Fail "abc") == TT (FailP "abc") (Fail "abc") "xxx" []
True
>>>
(TT ValP (Val True) "xxx" [] & ttValBool %~ id) == TT TrueP (Val True) "xxx" []
True
>>>
(TT FalseP (Val True) "xxx" [] & ttValBool %~ id) == TT TrueP (Val True) "xxx" []
True
PE untyped tree
untyped child node for TT
Instances
Eq PE Source # | |
Data PE Source # | |
Defined in Predicate.Util gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PE -> c PE # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PE # dataTypeOf :: PE -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PE) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PE) # gmapT :: (forall b. Data b => b -> b) -> PE -> PE # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PE -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PE -> r # gmapQ :: (forall d. Data d => d -> u) -> PE -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PE -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PE -> m PE # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PE -> m PE # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PE -> m PE # | |
Read PE Source # | |
Show PE Source # | |
Generic PE Source # | |
Semigroup PE Source # | |
Monoid PE Source # | |
type Rep PE Source # | |
Defined in Predicate.Util type Rep PE = D1 ('MetaData "PE" "Predicate.Util" "predicate-typed-0.7.4.5-JjMXzrXEzX77YMQbrq7lii" 'False) (C1 ('MetaCons "PE" 'PrefixI 'True) (S1 ('MetaSel ('Just "_peValP") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ValP) :*: S1 ('MetaSel ('Just "_peString") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String))) |
ValP
contains the untyped result from evaluating an expression
Instances
Eq ValP Source # | |
Data ValP Source # | |
Defined in Predicate.Util gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ValP -> c ValP # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ValP # dataTypeOf :: ValP -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ValP) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ValP) # gmapT :: (forall b. Data b => b -> b) -> ValP -> ValP # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ValP -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ValP -> r # gmapQ :: (forall d. Data d => d -> u) -> ValP -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ValP -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ValP -> m ValP # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ValP -> m ValP # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ValP -> m ValP # | |
Ord ValP Source # | |
Read ValP Source # | |
Show ValP Source # | |
Generic ValP Source # | |
Semigroup ValP Source # | semigroup for ValP
|
Monoid ValP Source # | |
type Rep ValP Source # | |
Defined in Predicate.Util type Rep ValP = D1 ('MetaData "ValP" "Predicate.Util" "predicate-typed-0.7.4.5-JjMXzrXEzX77YMQbrq7lii" 'False) ((C1 ('MetaCons "FailP" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)) :+: C1 ('MetaCons "FalseP" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TrueP" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ValP" 'PrefixI 'False) (U1 :: Type -> Type))) |
create tree
mkNode :: POpts -> Val a -> String -> [Tree PE] -> TT a Source #
creates a Node for the evaluation tree
mkNodeB :: POpts -> Bool -> String -> [Tree PE] -> TT Bool Source #
creates a Boolean node for a predicate type
mkNodeCopy :: POpts -> TT a -> String -> [Tree PE] -> TT a Source #
creates a Node for the evaluation tree
tree manipulation
getValAndPE :: TT a -> (Either String a, Tree PE) Source #
convenience method to pull parts out of TT
getValLRFromTT :: TT a -> Either String a Source #
convenience method to pull out the return value from TT
getValueLR :: Inline -> POpts -> String -> TT a -> [Tree PE] -> Either (TT x) a Source #
decorate the tree with more detail when there are errors but inline the error node
flag for deciding whether to inline a tree or extend it
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 return a tree with context
verboseList :: POpts -> TT a -> [Tree PE] Source #
return a singleton list of Tree if in verbose mode
topMessage :: TT a -> String Source #
extract message part from tree
hasNoTree :: POpts -> Bool Source #
returns True if there the debug option supports a display in tree format
options
how much detail to show in the expression tree
DZero | one line summary used mainly for testing |
DLite | one line summary with additional context from the top of the evaluation tree |
DNormal | outputs the evaluation tree but skips noisy subtrees |
DVerbose | outputs the entire evaluation tree |
display format for the tree
flag for showing long or short output
setOtherEffects :: POpts -> String -> String Source #
render a string for messages using optional color and underline
type Color1 = 'OColor "color1" 'Default 'Blue 'Default 'Red 'Black 'Cyan 'Black 'Yellow Source #
color palette for general display
type Color2 = 'OColor "color2" 'Default 'Magenta 'Default 'Red 'Black 'White 'Black 'Yellow Source #
color palette for general display
type Color3 = 'OColor "color3" 'Default 'Blue 'Red 'Default 'White 'Default 'Black 'Yellow Source #
color palette for general display
type Color4 = 'OColor "color4" 'Default 'Red 'Red 'Default 'Green 'Default 'Black 'Yellow Source #
color palette for general display
type Color5 = 'OColor "color5" 'Blue 'Default 'Red 'Default 'Cyan 'Default 'Yellow 'Default Source #
color palette for general display
type Other1 = 'OOther 'Underline 'Yellow 'Default Source #
color palette for effects used in Msg
and the refined modules
type Other2 = 'OOther 'Underline 'Default 'Default Source #
color palette for effects used in Msg
and the refined modules
customizable options for running a typelevel expression
HOpts | |
|
Display options
OEmpty | mempty |
OWidth !Nat | set display width |
OMsg !Symbol | set text to add context to a failure message for refined types |
ORecursion !Nat | set recursion limit eg for regex |
ORecursionLarge !Nat | set recursion limit for large fields |
OLarge !Bool | use large recursion |
OOther | set effects for messages |
!Opt :# !Opt infixr 6 | mappend |
OColor | set color palette |
OColorOn | turn on colors |
OColorOff | turn off colors |
OAnsi | ansi display |
OUnicode | unicode display |
OZero | debug mode return nothing |
OLite | debug mode return one line |
ONormal | debug mode normal |
OVerbose | debug mode verbose |
OZ | composite: no messages |
OL | composite: lite version |
OA | composite: ansi + colors |
OAB | composite: ansi + colors + background |
OAN | composite: ansi + no colors |
OAV | composite: ansi + colors + verbose |
OANV | composite: ansi + no colors + verbose |
OU | composite: unicode + colors |
OUB | composite: unicode + colors + background |
OUN | composite: unicode + no colors |
OUV | composite: unicode + colors + verbose |
OUNV | composite: unicode + no colors + verbose |
class OptC (k :: Opt) Source #
extract options from the typelevel
getOptC
Instances
type family OptT (xs :: [Opt]) where ... Source #
mconcat Opt
options at the type level
>>>
x = getOpt @(OptT '[ 'OMsg "test", 'ORecursion 123, OU, OL, 'OMsg "field2"])
>>>
oMsg x
["test","field2"]>>>
oRecursion x
123
getOpt :: forall o. OptC o => POpts Source #
convert typelevel options to POpts
>>>
(oDisp &&& fst . oColor &&& oWidth) (getOpt @(OA ':# OU ':# OA ':# 'OWidth 321 ':# Color4 ':# 'OMsg "test message"))
(Ansi,("color4",321))
>>>
oMsg (getOpt @('OMsg "abc" ':# 'OMsg "def"))
["abc","def"]
>>>
oOther (getOpt @('OOther 'Normal 'Red 'White ':# 'OOther 'Underline 'Red 'Black))
(Underline,Red,Black)
>>>
a = show (getOpt @('OEmpty ':# OU))
>>>
b = show (getOpt @(OU ':# 'OEmpty));
>>>
c = show (getOpt @OU)
>>>
a==b && b==c
True
zeroToLite :: POpts -> POpts Source #
override options for DZero
so we dont lose error information: especially if we want to extract the topMessage and use it for Fail case
formatting functions
show3 :: (Show a1, Show a2) => POpts -> String -> a1 -> a2 -> String Source #
display a message and three values where the last one is displayed in verbose mode
show3' :: (Show a1, Show a2) => POpts -> String -> a1 -> String -> a2 -> String Source #
display a message and four values where the last two are displayed in verbose mode
lit3 :: Show a1 => POpts -> String -> a1 -> String -> String -> String Source #
display a message and four values where the last two are displayed in verbose mode
litVerbose :: POpts -> String -> String -> String Source #
more restrictive: only display data in verbose debug mode
showL :: Show a => POpts -> a -> String Source #
display a showable value limited to the width found in the options
litBL :: POpts -> ByteString -> String Source #
display lazy bytestring output up to the maximum width in the options
litBS :: POpts -> ByteString -> String Source #
display bytestring output up to the maximum width in the options
joinStrings :: String -> String -> String Source #
concatenate two strings with delimiter
>>>
joinStrings "xyz" "abc"
"xyz | abc"
>>>
joinStrings "" "abc"
"abc"
>>>
joinStrings "xyz" ""
"xyz"
>>>
joinStrings "" ""
""
printing methods
prtTree :: Show x => POpts -> TT x -> String Source #
render the output from TT depending on the debug options
MonadEval
class Monad m => MonadEval m where Source #
a typeclass for choosing which monad to run in
>>>
hasIO @IO
True
>>>
hasIO @Identity
False
runIO :: IO a -> m (Maybe a) Source #
catchit :: a -> m (Either String a) Source #
catchitNF :: NFData a => a -> m (Either String a) Source #
miscellaneous
chkSize :: Foldable t => POpts -> String -> t a -> [Tree PE] -> Either (TT x) (Int, [a]) Source #
deal with possible recursion on a list
chkSize2 :: (Foldable t, Foldable u) => POpts -> String -> t a -> u b -> [Tree PE] -> Either (TT x) ((Int, [a]), (Int, [b])) Source #
deal with possible recursion on two lists
badLength :: Int -> Int -> String Source #
message to display when the length of a foldable is exceeded
getMaxRecursionValue :: POpts -> Int Source #
get the current recursion value depending on the oLarge flag
lengthGreaterThanOne :: [a] -> Bool Source #
returns True if the list has more than one element