predicate-typed-0.7.4.0: Predicates, Refinement types and Dsl

Safe HaskellNone
LanguageHaskell2010

Predicate.Util

Contents

Description

utility methods for Predicate / methods for displaying the evaluation tree

Synopsis

Val

data Val a #

contains the typed result from evaluating an expression

Constructors

Fail !String 
Val !a 
Instances
Monad Val # 
Instance details

Defined in Predicate.Util

Methods

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

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

return :: a -> Val a #

fail :: String -> Val a #

Functor Val # 
Instance details

Defined in Predicate.Util

Methods

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

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

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

Defined in Predicate.Util

Methods

fold :: Monoid m => Val m -> 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 # 
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) # 
Instance details

Defined in Predicate.Util

Methods

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

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

Ord a => Ord (Val a) # 
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) # 
Instance details

Defined in Predicate.Util

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

Defined in Predicate.Util

Methods

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

show :: Val a -> String #

showList :: [Val a] -> ShowS #

Generic (Val a) # 
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) #

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

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

Defined in Predicate.Util

Associated Types

type Rep1 Val :: k -> Type #

Methods

from1 :: Val a -> Rep1 Val a #

to1 :: Rep1 Val a -> Val a #

type Rep (Val a) # 
Instance details

Defined in Predicate.Util

type Rep (Val a) = D1 (MetaData "Val" "Predicate.Util" "predicate-typed-0.7.4.0-AMxhQNc83qND3FQMGxAFxs" 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 # 
Instance details

Defined in Predicate.Util

type Rep1 Val = D1 (MetaData "Val" "Predicate.Util" "predicate-typed-0.7.4.0-AMxhQNc83qND3FQMGxAFxs" 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 #

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

_True :: a ~ Bool => Prism' (Val a) () #

prism for Val True

>>> Val True ^? _True
Just ()
>>> Val False ^? _True
Nothing

_False :: a ~ Bool => Prism' (Val a) () #

prism for Val False

>>> (_True # ()) ^? _True
Just ()
>>> (_False # ()) ^? _False
Just ()
>>> Val False ^? _False
Just ()
>>> Val True ^? _False
Nothing

_ValEither :: Iso (Val a) (Val b) (Either String a) (Either String b) #

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

val2P :: Lens' (Val a) ValP #

a lens from typed Val to the untyped ValP

>>> Val True ^. val2P
ValP
>>> Val 123 ^. val2P
ValP
>>> Fail "abc" ^. val2P
FailP "abc"

val2PBool :: a ~ Bool => Lens' (Val a) ValP #

a lens from typed Val Bool to the untyped ValP

>>> Val True ^. val2PBool
TrueP
>>> Val False ^. val2PBool
FalseP
>>> Fail "abc" ^. val2PBool
FailP "abc"

TT typed tree

data TT a #

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

Constructors

TT 

Fields

Instances
Monad TT # 
Instance details

Defined in Predicate.Util

Methods

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

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

return :: a -> TT a #

fail :: String -> TT a #

Functor TT # 
Instance details

Defined in Predicate.Util

Methods

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

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

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

Defined in Predicate.Util

Methods

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 #

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

Defined in Predicate.Util

Methods

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

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

Read a => Read (TT a) # 
Instance details

Defined in Predicate.Util

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

Defined in Predicate.Util

Methods

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

show :: TT a -> String #

showList :: [TT a] -> ShowS #

Generic (TT a) # 
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) # 
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) # 
Instance details

Defined in Predicate.Util

Methods

mempty :: TT a #

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

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

Generic1 TT # 
Instance details

Defined in Predicate.Util

Associated Types

type Rep1 TT :: k -> Type #

Methods

from1 :: TT a -> Rep1 TT a #

to1 :: Rep1 TT a -> TT a #

type Rep (TT a) # 
Instance details

Defined in Predicate.Util

type Rep (TT a) = D1 (MetaData "TT" "Predicate.Util" "predicate-typed-0.7.4.0-AMxhQNc83qND3FQMGxAFxs" 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 # 
Instance details

Defined in Predicate.Util

ttVal :: Lens (TT a) (TT b) (Val a) (Val b) #

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

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 #

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

PE untyped tree

data PE #

untyped child node for TT

Constructors

PE 

Fields

Instances
Eq PE # 
Instance details

Defined in Predicate.Util

Methods

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

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

Read PE # 
Instance details

Defined in Predicate.Util

Show PE # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> PE -> ShowS #

show :: PE -> String #

showList :: [PE] -> ShowS #

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

Defined in Predicate.Util

Methods

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

sconcat :: NonEmpty PE -> PE #

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

Monoid PE # 
Instance details

Defined in Predicate.Util

Methods

mempty :: PE #

mappend :: PE -> PE -> PE #

mconcat :: [PE] -> PE #

type Rep PE # 
Instance details

Defined in Predicate.Util

type Rep PE = D1 (MetaData "PE" "Predicate.Util" "predicate-typed-0.7.4.0-AMxhQNc83qND3FQMGxAFxs" False) (C1 (MetaCons "PE" PrefixI True) (S1 (MetaSel (Just "_peValP") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ValP) :*: S1 (MetaSel (Just "_peString") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 String)))

peValP :: Lens' PE ValP #

peString :: Lens' PE String #

ValP

data ValP #

contains the untyped result from evaluating an expression

Constructors

FailP !String

evaluation failed

FalseP

False predicate

TrueP

True predicate

ValP

Any value

Instances
Eq ValP # 
Instance details

Defined in Predicate.Util

Methods

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

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

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

Defined in Predicate.Util

Show ValP # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> ValP -> ShowS #

show :: ValP -> String #

showList :: [ValP] -> ShowS #

Generic ValP # 
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 #

semigroup for ValP

>>> TrueP <> FalseP <> ValP
ValP
>>> ValP <> TrueP <> FalseP
FalseP
>>> 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 # 
Instance details

Defined in Predicate.Util

Methods

mempty :: ValP #

mappend :: ValP -> ValP -> ValP #

mconcat :: [ValP] -> ValP #

type Rep ValP # 
Instance details

Defined in Predicate.Util

type Rep ValP = D1 (MetaData "ValP" "Predicate.Util" "predicate-typed-0.7.4.0-AMxhQNc83qND3FQMGxAFxs" 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)))

_FailP :: Prism' ValP String #

_TrueP :: Prism' ValP () #

_FalseP :: Prism' ValP () #

_ValP :: Prism' ValP () #

create tree

mkNode :: POpts -> Val a -> String -> [Tree PE] -> TT a #

creates a Node for the evaluation tree

mkNodeB :: POpts -> Bool -> String -> [Tree PE] -> TT Bool #

creates a Boolean node for a predicate type

mkNodeCopy :: POpts -> TT a -> String -> [Tree PE] -> TT a #

creates a Node for the evaluation tree

tree manipulation

getValAndPE :: TT a -> (Either String a, Tree PE) #

convenience method to pull parts out of TT

getValLRFromTT :: TT a -> Either String a #

convenience method to pull out the return value from TT

getValueLR :: Inline -> POpts -> String -> TT a -> [Tree PE] -> Either (TT x) a #

decorate the tree with more detail when there are errors but inline the error node

data Inline #

Constructors

Inline 
NoInline 
Instances
Eq Inline # 
Instance details

Defined in Predicate.Util

Methods

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

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

Show Inline # 
Instance details

Defined in Predicate.Util

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

render numbered tree

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

prefix text in front of ttString

splitAndAlign :: Show x => POpts -> String -> [((Int, x), TT a)] -> Either (TT w) [(a, (Int, x), TT a)] #

extract values from the trees or if there are errors return a tree with context

verboseList :: POpts -> TT a -> [Tree PE] #

fixTTBool :: TT Bool -> TT Bool #

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 #

extract message part from tree

options

type POpts = HOpts Identity #

final set of options using Identity

data Debug #

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

Defined in Predicate.Util

Enum Debug # 
Instance details

Defined in Predicate.Util

Eq Debug # 
Instance details

Defined in Predicate.Util

Methods

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

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

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

Defined in Predicate.Util

Show Debug # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> Debug -> ShowS #

show :: Debug -> String #

showList :: [Debug] -> ShowS #

data Disp #

display format for the tree

Constructors

Ansi

draw normal tree

Unicode

use unicode

Instances
Bounded Disp # 
Instance details

Defined in Predicate.Util

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

Defined in Predicate.Util

Methods

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

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

Read Disp # 
Instance details

Defined in Predicate.Util

Show Disp # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> Disp -> ShowS #

show :: Disp -> String #

showList :: [Disp] -> ShowS #

data Color #

Instances
Enum Color 
Instance details

Defined in System.Console.Pretty

isVerbose :: POpts -> Bool #

verbose debug flag

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

render ValP value with colors

data Long #

Constructors

Long 
Short 
Instances
Eq Long # 
Instance details

Defined in Predicate.Util

Methods

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

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

Show Long # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> Long -> ShowS #

show :: Long -> String #

showList :: [Long] -> ShowS #

setOtherEffects :: POpts -> String -> String #

render a string for messages using optional color and underline

type Color1 = OColor "color1" Default Blue Default Red Black Cyan Black Yellow #

color palettes

type OZ = OZ #

option synonyms to save a keystroke

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 #

customizable options for running a typelevel expression

Constructors

HOpts 

Fields

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

Defined in Predicate.Util

Methods

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

show :: HOpts f -> String #

showList :: [HOpts f] -> ShowS #

Semigroup (HOpts Last) # 
Instance details

Defined in Predicate.Util

Monoid (HOpts Last) #

monoid opts

Instance details

Defined in Predicate.Util

data Opt #

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

OOther

set effects for messages

Fields

  • !Bool

    set underline

  • !Color

    set foreground color

  • !Color

    set background color

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

extract options from the typelevel

Minimal complete definition

getOptC

Instances
OptC OEmpty # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OColorOn # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OColorOff # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OAnsi # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OUnicode # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OZero # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OLite # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC ONormal # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OVerbose # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OZ # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OL # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OA # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OAB # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OAN # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OAV # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OANV # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OU # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OUB # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OUN # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OUV # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

OptC OUNV # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

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

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

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

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

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

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

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

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

(GetBool b, GetColor c1, GetColor c2) => OptC (OOther b c1 c2) # 
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) # 
Instance details

Defined in Predicate.Util

Methods

getOptC :: HOpts Last

type family OptT (xs :: [Opt]) where ... #

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 #

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 'False 'Red 'White ':# 'OOther 'True 'Red 'Black))
(True,Red,Black)
>>> a = show (getOpt @('OEmpty ':# OU))
>>> b = show (getOpt @(OU ':# 'OEmpty));
>>> c = show (getOpt @OU)
>>> a==b && b==c
True

subopts :: POpts -> POpts #

override options for DZero so we dont lose error information

_DVerbose :: Traversal' POpts () #

traversal for DVerbose

>>> has _DVerbose (getOpt @OU)
False
>>> has _DVerbose (getOpt @OUV)
True

_Debug :: Lens' POpts Debug #

defOpts :: POpts #

default options

formatting functions

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 #

more restrictive: only display data in verbose debug mode

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

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

printing methods

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

display tree

formatOMsg :: POpts -> String -> String #

pretty print a message

prtTree :: Show x => POpts -> TT x -> String #

MonadEval

class Monad m => MonadEval m where #

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

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

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

liftEval :: m a -> IO a #

hasIO :: Bool #

Instances
MonadEval IO #

IO instance for evaluating the expression

Instance details

Defined in Predicate.Util

Methods

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

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

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

liftEval :: IO a -> IO a #

hasIO :: Bool #

MonadEval Identity #

Identity instance for evaluating the expression

Instance details

Defined in Predicate.Util

Methods

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

catchit :: a -> Identity (Either String a) #

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

liftEval :: Identity a -> IO a #

hasIO :: Bool #

miscellaneous

hh :: TT a -> Tree PE #

converts a typed tree to an untyped tree for display

chkSize :: Foldable t => POpts -> String -> t a -> [Tree PE] -> Either (TT x) [a] #

deal with possible recursion on a list

chkSize2 :: (Foldable t, Foldable u) => POpts -> String -> t a -> u b -> [Tree PE] -> Either (TT x) ([a], [b]) #

deal with possible recursion on two lists

badLength :: Foldable t => t a -> Int -> String #

message to display when the length of a foldable is exceeded