predicate-typed-0.7.4.5: Predicates, Refinement types and Dsl
Safe HaskellNone
LanguageHaskell2010

Predicate.Util

Description

utility methods

Synopsis

Val

data Val a Source #

contains the typed result from evaluating an expression

Constructors

Fail !String 
Val !a 

Instances

Instances details
Monad Val Source # 
Instance details

Defined in Predicate.Util

Methods

(>>=) :: Val a -> (a -> Val b) -> Val b #

(>>) :: Val a -> Val b -> Val b #

return :: a -> Val a #

Functor Val Source # 
Instance details

Defined in Predicate.Util

Methods

fmap :: (a -> b) -> Val a -> Val b #

(<$) :: a -> Val b -> Val a #

Applicative Val Source # 
Instance details

Defined in Predicate.Util

Methods

pure :: a -> Val a #

(<*>) :: Val (a -> b) -> Val a -> Val b #

liftA2 :: (a -> b -> c) -> Val a -> Val b -> Val c #

(*>) :: Val a -> Val b -> Val b #

(<*) :: Val a -> Val b -> Val a #

Foldable Val Source # 
Instance details

Defined in Predicate.Util

Methods

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 #

toList :: Val a -> [a] #

null :: Val a -> Bool #

length :: Val a -> Int #

elem :: Eq a => a -> Val a -> Bool #

maximum :: Ord a => Val a -> a #

minimum :: Ord a => Val a -> a #

sum :: Num a => Val a -> a #

product :: Num a => Val a -> a #

Traversable Val Source # 
Instance details

Defined in Predicate.Util

Methods

traverse :: Applicative f => (a -> f b) -> Val a -> f (Val b) #

sequenceA :: Applicative f => Val (f a) -> f (Val a) #

mapM :: Monad m => (a -> m b) -> Val a -> m (Val b) #

sequence :: Monad m => Val (m a) -> m (Val a) #

Eq a => Eq (Val a) Source # 
Instance details

Defined in Predicate.Util

Methods

(==) :: Val a -> Val a -> Bool #

(/=) :: Val a -> Val a -> Bool #

Data a => Data (Val a) Source # 
Instance details

Defined in Predicate.Util

Methods

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) #

toConstr :: Val a -> Constr #

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 # 
Instance details

Defined in Predicate.Util

Methods

compare :: Val a -> Val a -> Ordering #

(<) :: Val a -> Val a -> Bool #

(<=) :: Val a -> Val a -> Bool #

(>) :: Val a -> Val a -> Bool #

(>=) :: Val a -> Val a -> Bool #

max :: Val a -> Val a -> Val a #

min :: Val a -> Val a -> Val a #

Read a => Read (Val a) Source # 
Instance details

Defined in Predicate.Util

Show a => Show (Val a) Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> Val a -> ShowS #

show :: Val a -> String #

showList :: [Val a] -> ShowS #

Generic (Val a) Source # 
Instance details

Defined in Predicate.Util

Associated Types

type Rep (Val a) :: Type -> Type #

Methods

from :: Val a -> Rep (Val a) x #

to :: Rep (Val a) x -> Val a #

Semigroup (Val a) Source #

semigroup instance for Val

>>> Val 123 <> (Val 456 <> Val 789) == (Val 123 <> Val 456) <> Val 789
True
>>> Val True <> Val False
Val False
>>> Val True <> Val True
Val True
>>> Fail "abc" <> (Val True <> Val False) <> Fail "def"
Fail "abc | def"
>>> (Fail "abc" <> Val True) <> (Val False <> Fail "def")
Fail "abc | def"
>>> Fail "" <> (Val True <> Val False) <> Fail "def"
Fail "def"
>>> Fail "abc" <> Fail "" <> Fail "def"
Fail "abc | def"
>>> Val False <> (Val True <> Val False) == (Val False <> Val True) <> Val False
True
Instance details

Defined in Predicate.Util

Methods

(<>) :: Val a -> Val a -> Val a #

sconcat :: NonEmpty (Val a) -> Val a #

stimes :: Integral b => b -> Val a -> Val a #

Monoid a => Monoid (Val a) Source #

monoid instance for Val

>>> mempty :: Val (Maybe [Int])
Val Nothing
>>> import qualified Data.Semigroup as SG
>>> mempty :: SG.Sum Int
Sum {getSum = 0}
Instance details

Defined in Predicate.Util

Methods

mempty :: Val a #

mappend :: Val a -> Val a -> Val a #

mconcat :: [Val a] -> Val a #

Generic1 Val Source # 
Instance details

Defined in Predicate.Util

Associated Types

type Rep1 Val :: k -> Type #

Methods

from1 :: forall (a :: k). Val a -> Rep1 Val a #

to1 :: forall (a :: k). Rep1 Val a -> Val a #

type Rep (Val a) Source # 
Instance details

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 # 
Instance details

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))

_Fail :: forall a. Prism' (Val a) String Source #

_Val :: forall a a. Prism (Val a) (Val a) a a Source #

_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

data TT a Source #

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

Instances details
Monad TT Source # 
Instance details

Defined in Predicate.Util

Methods

(>>=) :: TT a -> (a -> TT b) -> TT b #

(>>) :: TT a -> TT b -> TT b #

return :: a -> TT a #

Functor TT Source # 
Instance details

Defined in Predicate.Util

Methods

fmap :: (a -> b) -> TT a -> TT b #

(<$) :: a -> TT b -> TT a #

Applicative TT Source # 
Instance details

Defined in Predicate.Util

Methods

pure :: a -> TT a #

(<*>) :: TT (a -> b) -> TT a -> TT b #

liftA2 :: (a -> b -> c) -> TT a -> TT b -> TT c #

(*>) :: TT a -> TT b -> TT b #

(<*) :: TT a -> TT b -> TT a #

Foldable TT Source # 
Instance details

Defined in Predicate.Util

Methods

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 #

toList :: TT a -> [a] #

null :: TT a -> Bool #

length :: TT a -> Int #

elem :: Eq a => a -> TT a -> Bool #

maximum :: Ord a => TT a -> a #

minimum :: Ord a => TT a -> a #

sum :: Num a => TT a -> a #

product :: Num a => TT a -> a #

Traversable TT Source # 
Instance details

Defined in Predicate.Util

Methods

traverse :: Applicative f => (a -> f b) -> TT a -> f (TT b) #

sequenceA :: Applicative f => TT (f a) -> f (TT a) #

mapM :: Monad m => (a -> m b) -> TT a -> m (TT b) #

sequence :: Monad m => TT (m a) -> m (TT a) #

Eq a => Eq (TT a) Source # 
Instance details

Defined in Predicate.Util

Methods

(==) :: TT a -> TT a -> Bool #

(/=) :: TT a -> TT a -> Bool #

Data a => Data (TT a) Source # 
Instance details

Defined in Predicate.Util

Methods

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) #

toConstr :: TT a -> Constr #

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 # 
Instance details

Defined in Predicate.Util

Show a => Show (TT a) Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> TT a -> ShowS #

show :: TT a -> String #

showList :: [TT a] -> ShowS #

Generic (TT a) Source # 
Instance details

Defined in Predicate.Util

Associated Types

type Rep (TT a) :: Type -> Type #

Methods

from :: TT a -> Rep (TT a) x #

to :: Rep (TT a) x -> TT a #

Semigroup (TT a) Source # 
Instance details

Defined in Predicate.Util

Methods

(<>) :: TT a -> TT a -> TT a #

sconcat :: NonEmpty (TT a) -> TT a #

stimes :: Integral b => b -> TT a -> TT a #

Monoid a => Monoid (TT a) Source # 
Instance details

Defined in Predicate.Util

Methods

mempty :: TT a #

mappend :: TT a -> TT a -> TT a #

mconcat :: [TT a] -> TT a #

Generic1 TT Source # 
Instance details

Defined in Predicate.Util

Associated Types

type Rep1 TT :: k -> Type #

Methods

from1 :: forall (a :: k). TT a -> Rep1 TT a #

to1 :: forall (a :: k). Rep1 TT a -> TT a #

type Rep (TT a) Source # 
Instance details

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 # 
Instance details

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

ttString :: forall a. Lens' (TT a) String Source #

ttForest :: forall a. Lens' (TT a) (Forest PE) Source #

PE untyped tree

data PE Source #

untyped child node for TT

Constructors

PE 

Fields

Instances

Instances details
Eq PE Source # 
Instance details

Defined in Predicate.Util

Methods

(==) :: PE -> PE -> Bool #

(/=) :: PE -> PE -> Bool #

Data PE Source # 
Instance details

Defined in Predicate.Util

Methods

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 #

toConstr :: PE -> Constr #

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 # 
Instance details

Defined in Predicate.Util

Show PE Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> PE -> ShowS #

show :: PE -> String #

showList :: [PE] -> ShowS #

Generic PE Source # 
Instance details

Defined in Predicate.Util

Associated Types

type Rep PE :: Type -> Type #

Methods

from :: PE -> Rep PE x #

to :: Rep PE x -> PE #

Semigroup PE Source # 
Instance details

Defined in Predicate.Util

Methods

(<>) :: PE -> PE -> PE #

sconcat :: NonEmpty PE -> PE #

stimes :: Integral b => b -> PE -> PE #

Monoid PE Source # 
Instance details

Defined in Predicate.Util

Methods

mempty :: PE #

mappend :: PE -> PE -> PE #

mconcat :: [PE] -> PE #

type Rep PE Source # 
Instance details

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

data ValP Source #

contains the untyped result from evaluating an expression

Constructors

FailP !String

evaluation failed

FalseP

False predicate

TrueP

True predicate

ValP

Any value

Instances

Instances details
Eq ValP Source # 
Instance details

Defined in Predicate.Util

Methods

(==) :: ValP -> ValP -> Bool #

(/=) :: ValP -> ValP -> Bool #

Data ValP Source # 
Instance details

Defined in Predicate.Util

Methods

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 #

toConstr :: ValP -> Constr #

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 # 
Instance details

Defined in Predicate.Util

Methods

compare :: ValP -> ValP -> Ordering #

(<) :: ValP -> ValP -> Bool #

(<=) :: ValP -> ValP -> Bool #

(>) :: ValP -> ValP -> Bool #

(>=) :: ValP -> ValP -> Bool #

max :: ValP -> ValP -> ValP #

min :: ValP -> ValP -> ValP #

Read ValP Source # 
Instance details

Defined in Predicate.Util

Show ValP Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> ValP -> ShowS #

show :: ValP -> String #

showList :: [ValP] -> ShowS #

Generic ValP Source # 
Instance details

Defined in Predicate.Util

Associated Types

type Rep ValP :: Type -> Type #

Methods

from :: ValP -> Rep ValP x #

to :: Rep ValP x -> ValP #

Semigroup ValP Source #

semigroup for ValP

>>> TrueP <> FalseP <> ValP
FalseP
>>> ValP <> TrueP <> FalseP
FalseP
>>> ValP <> TrueP <> ValP
TrueP
>>> FailP "abc" <> (TrueP <> FalseP) <> FailP "def"
FailP "abc | def"
>>> (FailP "abc" <> TrueP) <> (FalseP <> FailP "def")
FailP "abc | def"
>>> FailP "" <> (TrueP <> FalseP) <> FailP "def"
FailP "def"
>>> FailP "abc" <> FailP "" <> FailP "def"
FailP "abc | def"
>>> FailP "abc" <> FailP "xyz" <> FailP "def"
FailP "abc | xyz | def"
Instance details

Defined in Predicate.Util

Methods

(<>) :: ValP -> ValP -> ValP #

sconcat :: NonEmpty ValP -> ValP #

stimes :: Integral b => b -> ValP -> ValP #

Monoid ValP Source # 
Instance details

Defined in Predicate.Util

Methods

mempty :: ValP #

mappend :: ValP -> ValP -> ValP #

mconcat :: [ValP] -> ValP #

type Rep ValP Source # 
Instance details

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

data Inline Source #

flag for deciding whether to inline a tree or extend it

Constructors

Inline 
NoInline 

Instances

Instances details
Eq Inline Source # 
Instance details

Defined in Predicate.Util

Methods

(==) :: Inline -> Inline -> Bool #

(/=) :: Inline -> Inline -> Bool #

Show Inline Source # 
Instance details

Defined in Predicate.Util

prefixNumberToTT :: ((Int, x), TT a) -> TT a Source #

render numbered tree

prefixMsg :: String -> TT a -> TT a Source #

prefix text in front of ttString

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

fixTTBool :: TT Bool -> TT Bool Source #

fix the ValP value for the Bool case: ie use TrueP and FalseP

>>> fixTTBool (TT ValP (Val True) "x" []) == TT TrueP (Val True) "x" []
True
>>> fixTTBool (TT FalseP (Fail "abc") "x" []) == TT (FailP "abc") (Fail "abc") "x" []
True

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

type POpts = HOpts Identity Source #

final set of options using Identity

data Debug Source #

how much detail to show in the expression tree

Constructors

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

Instances

Instances details
Bounded Debug Source # 
Instance details

Defined in Predicate.Util

Enum Debug Source # 
Instance details

Defined in Predicate.Util

Eq Debug Source # 
Instance details

Defined in Predicate.Util

Methods

(==) :: Debug -> Debug -> Bool #

(/=) :: Debug -> Debug -> Bool #

Ord Debug Source # 
Instance details

Defined in Predicate.Util

Methods

compare :: Debug -> Debug -> Ordering #

(<) :: Debug -> Debug -> Bool #

(<=) :: Debug -> Debug -> Bool #

(>) :: Debug -> Debug -> Bool #

(>=) :: Debug -> Debug -> Bool #

max :: Debug -> Debug -> Debug #

min :: Debug -> Debug -> Debug #

Read Debug Source # 
Instance details

Defined in Predicate.Util

Show Debug Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> Debug -> ShowS #

show :: Debug -> String #

showList :: [Debug] -> ShowS #

data Disp Source #

display format for the tree

Constructors

Ansi

draw normal tree

Unicode

use unicode

Instances

Instances details
Bounded Disp Source # 
Instance details

Defined in Predicate.Util

Enum Disp Source # 
Instance details

Defined in Predicate.Util

Methods

succ :: Disp -> Disp #

pred :: Disp -> Disp #

toEnum :: Int -> Disp #

fromEnum :: Disp -> Int #

enumFrom :: Disp -> [Disp] #

enumFromThen :: Disp -> Disp -> [Disp] #

enumFromTo :: Disp -> Disp -> [Disp] #

enumFromThenTo :: Disp -> Disp -> Disp -> [Disp] #

Eq Disp Source # 
Instance details

Defined in Predicate.Util

Methods

(==) :: Disp -> Disp -> Bool #

(/=) :: Disp -> Disp -> Bool #

Read Disp Source # 
Instance details

Defined in Predicate.Util

Show Disp Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> Disp -> ShowS #

show :: Disp -> String #

showList :: [Disp] -> ShowS #

data Color #

Colors for an ANSI terminal

Instances

Instances details
Enum Color 
Instance details

Defined in System.Console.Pretty

isVerbose :: POpts -> Bool Source #

verbose debug flag

colorValBool :: POpts -> Val Bool -> String Source #

render coloured output for boolean values

colorValP :: Long -> POpts -> ValP -> String Source #

render ValP value with colors

data Long Source #

flag for showing long or short output

Constructors

Long 
Short 

Instances

Instances details
Eq Long Source # 
Instance details

Defined in Predicate.Util

Methods

(==) :: Long -> Long -> Bool #

(/=) :: Long -> Long -> Bool #

Show Long Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> Long -> ShowS #

show :: Long -> String #

showList :: [Long] -> ShowS #

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

type OZ = 'OZ Source #

debugging: no output

type OL = 'OL Source #

debugging: one line of summarised output without colors or effects

type OA = 'OA Source #

ascii output with colours

type OAB = 'OAB Source #

ascii output with colours and bold background

type OAN = 'OAN Source #

ascii output without colours

type OAV = 'OAV Source #

ascii output without colours

type OANV = 'OANV Source #

ascii output without colours

type OU = 'OU Source #

unicode output without colours

type OUB = 'OUB Source #

unicode output with colors and a bold background

type OUN = 'OUN Source #

unicode output without colours

type OUV = 'OUV Source #

unicode output verbose with colours

type OUNV = 'OUNV Source #

unicode output without colours and verbose

data HOpts f Source #

customizable options for running a typelevel expression

Constructors

HOpts 

Fields

Instances

Instances details
(Show (HKD f Int), Show (HKD f Debug), Show (HKD f Disp), Show (HKD f (String, PColor)), Show (HKD f Bool), Show (HKD f (SStyle, SColor, SColor))) => Show (HOpts f) Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> HOpts f -> ShowS #

show :: HOpts f -> String #

showList :: [HOpts f] -> ShowS #

Semigroup (HOpts Last) Source # 
Instance details

Defined in Predicate.Util

Monoid (HOpts Last) Source # 
Instance details

Defined in Predicate.Util

data Opt Source #

Display options

Constructors

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

Fields

!Opt :# !Opt infixr 6

mappend

OColor

set color palette

Fields

  • !Symbol

    name of color palette

  • !Color

    Fail foreground color

  • !Color

    Fail background color

  • !Color

    False foreground color

  • !Color

    False background color

  • !Color

    True foreground color

  • !Color

    True background color

  • !Color

    Present foreground color

  • !Color

    Present background color

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

Minimal complete definition

getOptC

Instances

Instances details
OptC 'OEmpty Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OColorOn Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OColorOff Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OAnsi Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OUnicode Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OZero Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OLite Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'ONormal Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OVerbose Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OZ Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OL Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OA Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OAB Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OAN Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OAV Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OANV Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OU Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OUB Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OUN Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OUV Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC 'OUNV Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

KnownNat n => OptC ('OWidth n) Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

KnownSymbol s => OptC ('OMsg s) Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

KnownNat n => OptC ('ORecursion n) Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

KnownNat n => OptC ('ORecursionLarge n) Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

GetBool b => OptC ('OLarge b) Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

(OptC a, OptC b) => OptC (a :# b) Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

(GetStyle s, GetColor c1, GetColor c2) => OptC ('OOther s c1 c2) Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

(KnownSymbol s, GetColor c1, GetColor c2, GetColor c3, GetColor c4, GetColor c5, GetColor c6, GetColor c7, GetColor c8) => OptC ('OColor s c1 c2 c3 c4 c5 c6 c7 c8) Source # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

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

Equations

OptT '[] = 'OEmpty 
OptT (x ': xs) = x :# OptT xs 

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

defOpts :: POpts Source #

default options

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

showVerbose :: Show a => POpts -> String -> a -> String Source #

show the value in verbose mode

showL :: Show a => POpts -> a -> String Source #

display a showable value limited to the width found in the options

litL :: POpts -> String -> String Source #

display a 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

prtTreePure :: POpts -> Tree PE -> String Source #

display tree

formatOMsg :: POpts -> String -> String Source #

pretty print a message

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

Minimal complete definition

runIO, catchit, catchitNF, liftEval

Methods

runIO :: IO a -> m (Maybe a) Source #

catchit :: a -> m (Either String a) Source #

catchitNF :: NFData a => a -> m (Either String a) Source #

liftEval :: m a -> IO a Source #

hasIO :: Bool Source #

Instances

Instances details
MonadEval IO Source #

IO instance for evaluating the expression

Instance details

Defined in Predicate.Util

Methods

runIO :: IO a -> IO (Maybe a) Source #

catchit :: a -> IO (Either String a) Source #

catchitNF :: NFData a => a -> IO (Either String a) Source #

liftEval :: IO a -> IO a Source #

hasIO :: Bool Source #

MonadEval Identity Source #

Identity instance for evaluating the expression

Instance details

Defined in Predicate.Util

miscellaneous

hh :: TT a -> Tree PE Source #

converts a typed tree to an untyped tree for display

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