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

Safe HaskellNone
LanguageHaskell2010

Predicate.Util

Contents

Description

Utility methods for Predicate / methods for displaying the evaluation tree

Synopsis

TT

data TT a Source #

represents the evaluation tree for predicates

Constructors

TT 

Fields

Instances
Foldable TT Source # 
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 #

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 #

tBool :: Lens (TT a) (TT b) (BoolT a) (BoolT b) Source #

lens for accessing BoolT in TT

tString :: Lens' (TT a) String Source #

lens for accessing the message from BoolT

tForest :: Lens' (TT a) (Forest PE) Source #

lens for accessing the subtree from BoolT

fixBoolT :: TT Bool -> TT Bool Source #

fix PresentT Bool to TrueT or FalseT

topMessage :: TT a -> String Source #

extract message part from tree

BoolT

data BoolT a where Source #

contains the typed result from evaluating the expression tree

Constructors

FailT :: !String -> BoolT a 
FalseT :: BoolT Bool 
TrueT :: BoolT Bool 
PresentT :: !a -> BoolT a 
Instances
Foldable BoolT Source # 
Instance details

Defined in Predicate.Util

Methods

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 #

toList :: BoolT a -> [a] #

null :: BoolT a -> Bool #

length :: BoolT a -> Int #

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

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

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

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

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

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

Defined in Predicate.Util

Methods

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

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

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

Defined in Predicate.Util

Methods

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

show :: BoolT a -> String #

showList :: [BoolT a] -> ShowS #

Semigroup (BoolT a) Source #

semigroup instance for BoolT

Instance details

Defined in Predicate.Util

Methods

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

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

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

GetBoolT x b => P (b :: BoolT x) a Source #

typelevel BoolT

>>> pz @'TrueT ()
TrueT
>>> pz @'FalseT ()
FalseT
>>> pz @('PresentT 123) ()
PresentT False
>>> pz @('FailT '[]) ()
FailT "'FailT _"
Instance details

Defined in Predicate.Core

Associated Types

type PP b a :: Type Source #

Methods

eval :: MonadEval m => proxy b -> POpts -> a -> m (TT (PP b a)) Source #

type PP (b :: BoolT x) a Source # 
Instance details

Defined in Predicate.Core

type PP (b :: BoolT x) a = Bool

class GetBoolT a (x :: BoolT a) | x -> a where Source #

extracts the 'BoolT a' constructors from the typelevel

Instances
GetBoolT Bool FalseT Source # 
Instance details

Defined in Predicate.Util

GetBoolT Bool TrueT Source # 
Instance details

Defined in Predicate.Util

GetBoolT a (FailT s :: BoolT a) Source # 
Instance details

Defined in Predicate.Util

GetBoolT a (PresentT b :: BoolT a) Source # 
Instance details

Defined in Predicate.Util

PE

data PE Source #

represents the untyped evaluation tree for final display

Instances
Show PE Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> PE -> ShowS #

show :: PE -> String #

showList :: [PE] -> ShowS #

pString :: Lens' PE String Source #

lens for accessing PE

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

tree manipulation

fromTT :: TT a -> Tree PE Source #

converts a typed tree to an untyped on for display

getValueLR :: POpts -> String -> TT a -> [Holder] -> Either (TT x) a Source #

add more detail to the tree if there are errors

fixLite :: forall a. Show a => POpts -> a -> Tree PE -> String Source #

override PresentP case if there is no tree ie lite or zero mode

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

render numbered tree

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

prefix text in front of tString

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

display options

type POptsL = HOpts Last Source #

monoid opts

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 head of the evaluation tree

DNormal

outputs the evaluation tree but skips noisy subtrees

DVerbose

outputs the entire evaluation tree

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

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

Defined in Predicate.Util

Methods

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

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

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
Enum Color 
Instance details

Defined in System.Console.Pretty

isVerbose :: POpts -> Bool Source #

verbose debug flag

colorBoolT :: Show a => POpts -> BoolT a -> String Source #

render the BoolT value with colors

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 palettes

type OZ = OAnsi :# (OColorOff :# OZero) Source #

combinations of options

data HOpts f Source #

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

Display options

Constructors

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

OEmpty

mempty

!OptT :# !OptT 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

OAN

composite: ansi + no colors

OANV

composite: ansi + no colors + verbose

OA

composite: ansi + colors

OAV

composite: ansi + colors + verbose

OAB

composite: ansi + colors + background

OU

composite: unicode + colors

OUB

composite: unicode + colors + background

OUV

composite: unicode + colors + verbose

Instances
Show OptT Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> OptT -> ShowS #

show :: OptT -> String #

showList :: [OptT] -> ShowS #

class OptTC (k :: OptT) where Source #

extract options from the typelevel

Instances
OptTC OEmpty Source # 
Instance details

Defined in Predicate.Util

OptTC OColorOn Source # 
Instance details

Defined in Predicate.Util

OptTC OColorOff Source # 
Instance details

Defined in Predicate.Util

OptTC OAnsi Source # 
Instance details

Defined in Predicate.Util

OptTC OUnicode Source # 
Instance details

Defined in Predicate.Util

OptTC OZero Source # 
Instance details

Defined in Predicate.Util

OptTC OLite Source # 
Instance details

Defined in Predicate.Util

OptTC ONormal Source # 
Instance details

Defined in Predicate.Util

OptTC OVerbose Source # 
Instance details

Defined in Predicate.Util

OptTC OZ Source # 
Instance details

Defined in Predicate.Util

OptTC OL Source # 
Instance details

Defined in Predicate.Util

OptTC OAN Source # 
Instance details

Defined in Predicate.Util

OptTC OANV Source # 
Instance details

Defined in Predicate.Util

OptTC OA Source # 
Instance details

Defined in Predicate.Util

OptTC OAV Source # 
Instance details

Defined in Predicate.Util

OptTC OAB Source # 
Instance details

Defined in Predicate.Util

OptTC OU Source # 
Instance details

Defined in Predicate.Util

OptTC OUB Source # 
Instance details

Defined in Predicate.Util

OptTC OUV Source # 
Instance details

Defined in Predicate.Util

KnownNat n => OptTC (OWidth n) Source # 
Instance details

Defined in Predicate.Util

KnownSymbol s => OptTC (OMsg s) Source # 
Instance details

Defined in Predicate.Util

KnownNat n => OptTC (ORecursion n) Source # 
Instance details

Defined in Predicate.Util

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

Defined in Predicate.Util

(GetBool b, GetColor c1, GetColor c2) => OptTC (OOther b c1 c2) Source # 
Instance details

Defined in Predicate.Util

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

Defined in Predicate.Util

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

mconcat OptT options at the type level

>>> x = getOptT @(OptTT '[ 'OMsg "test", 'ORecursion 123, OU, OL, 'OMsg "field2"])
>>> oMsg x
["test","field2"]
>>> oRecursion x
123

Equations

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

getOptT :: forall o. OptTC o => POpts Source #

convert typelevel options to POpts

>>> (oDisp &&& fst . oColor &&& oWidth) (getOptT @(OA ':# OU ':# OA ':# 'OWidth 321 ':# Color4 ':# 'OMsg "test message"))
(Ansi,("color4",321))
>>> oMsg (getOptT @('OMsg "abc" ':# 'OMsg "def"))
["abc","def"]
>>> oOther (getOptT @('OOther 'False 'Red 'White ':# 'OOther 'True 'Red 'Black))
(True,Red,Black)
>>> a = show (getOptT @('OEmpty ':# OU))
>>> b = show (getOptT @(OU ':# 'OEmpty));
>>> c = show (getOptT @OU)
>>> a==b && b==c
True

subopts :: POpts -> POpts Source #

override options for DZero so we dont lose error information

formatting functions

show01 :: (Show a1, Show a2) => POpts -> String -> a1 -> a2 -> String Source #

show01' :: (Show a1, Show a2) => POpts -> String -> a1 -> String -> a2 -> String Source #

lit01 :: Show a1 => POpts -> String -> a1 -> String -> String -> String Source #

litVerbose :: POpts -> String -> String -> String Source #

more restrictive: only display data in verbose debug mode

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

regular expressions

data ROpt Source #

Regex options for Rescan Resplit Re etc

Constructors

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

Defined in Predicate.Util

Enum ROpt Source # 
Instance details

Defined in Predicate.Util

Methods

succ :: ROpt -> ROpt #

pred :: ROpt -> ROpt #

toEnum :: Int -> ROpt #

fromEnum :: ROpt -> Int #

enumFrom :: ROpt -> [ROpt] #

enumFromThen :: ROpt -> ROpt -> [ROpt] #

enumFromTo :: ROpt -> ROpt -> [ROpt] #

enumFromThenTo :: ROpt -> ROpt -> ROpt -> [ROpt] #

Eq ROpt Source # 
Instance details

Defined in Predicate.Util

Methods

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

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

Ord ROpt Source # 
Instance details

Defined in Predicate.Util

Methods

compare :: ROpt -> ROpt -> Ordering #

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

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

(>) :: ROpt -> ROpt -> Bool #

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

max :: ROpt -> ROpt -> ROpt #

min :: ROpt -> ROpt -> ROpt #

Show ROpt Source # 
Instance details

Defined in Predicate.Util

Methods

showsPrec :: Int -> ROpt -> ShowS #

show :: ROpt -> String #

showList :: [ROpt] -> ShowS #

GetROpts ([] :: [ROpt]) Source # 
Instance details

Defined in Predicate.Util

Methods

getROpts :: ([String], [PCREOption]) Source #

(Typeable r, GetROpt r, GetROpts rs) => GetROpts (r ': rs) Source # 
Instance details

Defined in Predicate.Util

Methods

getROpts :: ([String], [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

Methods

getROpts :: ([String], [PCREOption]) Source #

Instances
GetROpts ([] :: [ROpt]) Source # 
Instance details

Defined in Predicate.Util

Methods

getROpts :: ([String], [PCREOption]) Source #

(Typeable r, GetROpt r, GetROpts rs) => GetROpts (r ': rs) Source # 
Instance details

Defined in Predicate.Util

Methods

getROpts :: ([String], [PCREOption]) Source #

data RReplace 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

Instances
Show RReplace Source # 
Instance details

Defined in Predicate.Util

class GetReplaceFnSub (k :: ReplaceFnSub) where Source #

extract replacement options from typelevel

data ReplaceFnSub Source #

simple regex string replacement options

Constructors

RPrepend 
ROverWrite 
RAppend 
Instances
Eq ReplaceFnSub Source # 
Instance details

Defined in Predicate.Util

Show ReplaceFnSub Source # 
Instance details

Defined in Predicate.Util

P (ReplaceAllStringT o p q r) x => P (ReplaceAllString o p q r :: Type) x Source # 
Instance details

Defined in Predicate.Data.Regex

Associated Types

type PP (ReplaceAllString o p q r) x :: Type Source #

Methods

eval :: MonadEval m => proxy (ReplaceAllString o p q r) -> POpts -> x -> m (TT (PP (ReplaceAllString o p q r) x)) Source #

type PP (ReplaceAllString o p q r :: Type) x Source # 
Instance details

Defined in Predicate.Data.Regex

type PP (ReplaceAllString o p q r :: Type) x

useful type families

type family ZwischenT (a :: Nat) (b :: Nat) (v :: Nat) :: Constraint where ... Source #

type level Between

Equations

ZwischenT m n v = FailUnlessT (AndT (m <=? v) (v <=? n)) (((Text "ZwischenT failure" :$$: ShowType v) :$$: Text " is outside of ") :$$: ((ShowType m :<>: Text " and ") :<>: ShowType n)) 

type family FailWhenT (b :: Bool) (msg :: ErrorMessage) :: Constraint where ... Source #

helper method that fails with a msg when True

Equations

FailWhenT False _ = () 
FailWhenT True e = TypeError e 

type family FailUnlessT (b :: Bool) (msg :: ErrorMessage) :: Constraint where ... Source #

helper method that fails with msg when False

Equations

FailUnlessT True _ = () 
FailUnlessT False e = TypeError e 

type family AndT (b :: Bool) (b1 :: Bool) :: Bool where ... Source #

typelevel boolean And

Equations

AndT False _ = False 
AndT True b1 = b1 

type family OrT (b :: Bool) (b1 :: Bool) :: Bool where ... Source #

typelevel boolean Or

Equations

OrT True _ = True 
OrT False b1 = b1 

type family NotT (b :: Bool) :: Bool where ... Source #

typelevel boolean Not

Equations

NotT True = False 
NotT False = True 

type family RepeatT (n :: Nat) (p :: k) :: [k] where ... Source #

Repeat an expression n times

Equations

RepeatT 0 p = TypeError (Text "RepeatT is not defined for zero") 
RepeatT 1 p = p ': '[] 
RepeatT n p = p ': RepeatT (n - 1) p 

type family IntersperseT (s :: Symbol) (xs :: [Symbol]) :: Symbol where ... Source #

Intersperse a symbol inside a list of symbols

Equations

IntersperseT s '[] = "" 
IntersperseT s '[x] = x 
IntersperseT s (x ': (y ': xs)) = x <%> (s <%> IntersperseT s (y ': xs)) 

type family LenT (xs :: [k]) :: Nat where ... Source #

length of a type level list

Equations

LenT '[] = 0 
LenT (x ': xs) = 1 + LenT 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,()))

Associated Types

type InductTupleP x Source #

Instances
(TypeError (Text "InductTupleC: inductive tuple cannot be empty") :: Constraint) => InductTupleC () Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductTupleP () :: Type Source #

Methods

inductTupleC :: () -> InductTupleP () Source #

InductTupleC (a, b) Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b) :: Type Source #

Methods

inductTupleC :: (a, b) -> InductTupleP (a, b) Source #

InductTupleC (a, b, c) Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c) :: Type Source #

Methods

inductTupleC :: (a, b, c) -> InductTupleP (a, b, c) Source #

InductTupleC (a, b, c, d) Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c, d) :: Type Source #

Methods

inductTupleC :: (a, b, c, d) -> InductTupleP (a, b, c, d) Source #

InductTupleC (a, b, c, d, e) Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c, d, e) :: Type Source #

Methods

inductTupleC :: (a, b, c, d, e) -> InductTupleP (a, b, c, d, e) Source #

InductTupleC (a, b, c, d, e, f) Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c, d, e, f) :: Type Source #

Methods

inductTupleC :: (a, b, c, d, e, f) -> InductTupleP (a, b, c, d, e, f) Source #

InductTupleC (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c, d, e, f, g) :: Type Source #

Methods

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

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c, d, e, f, g, h) :: Type Source #

Methods

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

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c, d, e, f, g, h, i) :: Type Source #

Methods

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

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c, d, e, f, g, h, i, j) :: Type Source #

Methods

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

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c, d, e, f, g, h, i, j, k) :: Type Source #

Methods

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

Defined in Predicate.Util

Associated Types

type InductTupleP (a, b, c, d, e, f, g, h, i, j, k, l) :: Type Source #

Methods

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

Associated Types

type InductListP n a Source #

Methods

inductListC :: [a] -> InductListP n a Source #

Instances
(TypeError (Text "InductListC: inductive tuple cannot be empty") :: Constraint) => InductListC 0 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 0 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 0 a Source #

InductListC 1 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 1 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 1 a Source #

InductListC 2 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 2 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 2 a Source #

InductListC 3 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 3 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 3 a Source #

InductListC 4 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 4 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 4 a Source #

InductListC 5 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 5 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 5 a Source #

InductListC 6 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 6 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 6 a Source #

InductListC 7 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 7 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 7 a Source #

InductListC 8 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 8 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 8 a Source #

InductListC 9 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 9 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 9 a Source #

InductListC 10 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 10 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 10 a Source #

InductListC 11 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 11 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 11 a Source #

InductListC 12 a Source # 
Instance details

Defined in Predicate.Util

Associated Types

type InductListP 12 a :: Type Source #

Methods

inductListC :: [a] -> InductListP 12 a Source #

type family FlipT (d :: k1 -> k -> k2) (p :: k) (q :: k1) :: k2 where ... Source #

flip at the type level

Equations

FlipT d p q = d q p 

type family IfT (b :: Bool) (t :: k) (f :: k) :: k where ... Source #

'if' at the type level

Equations

IfT True t f = t 
IfT False t f = f 

type family SumT (ns :: [Nat]) :: Nat where ... Source #

sum at the type level for a list of Nat

Equations

SumT '[] = 0 
SumT (n ': ns) = n + SumT ns 

type family MapT (f :: k -> k1) (xs :: [k]) :: [k1] where ... Source #

map at the type level

Equations

MapT f '[] = '[] 
MapT f (x ': xs) = f x ': MapT f xs 

type family ConsT s where ... Source #

Extract 'a' from a list-like container

Equations

ConsT [a] = a 
ConsT (ZipList a) = a 
ConsT Text = Char 
ConsT ByteString = Word8 
ConsT (Seq a) = a 
ConsT s = TypeError (Text "invalid ConsT instance" :$$: (Text "s = " :<>: ShowType s)) 

type family (p :: k -> k1) %% (q :: k) :: k1 where ... infixl 9 Source #

Equations

p %% q = p q 

type family (p :: k) %& (q :: k -> k1) :: k1 where ... infixr 9 Source #

Equations

p %& q = q p 

type (<%>) s t = AppendSymbol s t infixr 7 Source #

type family AnyT :: k where ... Source #

represents any kind

type family ExtractAFromList (as :: Type) :: Type where ... Source #

type family to extract 'a' from a list of 'a'

Equations

ExtractAFromList [a] = a 
ExtractAFromList z = TypeError (Text "ExtractAFromList: expected [a] but found something else" :$$: (Text "as = " :<>: ShowType z)) 

type family ExtractAFromTA (ta :: Type) :: Type where ... Source #

type family to extract 'a' from 't a'

Equations

ExtractAFromTA (t a) = a 
ExtractAFromTA z = TypeError (Text "ExtractAFromTA: expected (t a) but found something else" :$$: (Text "t a = " :<>: ShowType z)) 

type family MaybeT mb where ... Source #

Equations

MaybeT (Maybe a) = a 
MaybeT o = TypeError (Text "MaybeT: expected 'Maybe a' " :$$: (Text "o = " :<>: ShowType o)) 

type family LeftT lr where ... Source #

Equations

LeftT (Either a _) = a 
LeftT o = TypeError (Text "LeftT: expected 'Either a b' " :$$: (Text "o = " :<>: ShowType o)) 

type family RightT lr where ... Source #

Equations

RightT (Either a b) = b 
RightT o = TypeError (Text "RightT: expected 'Either a b' " :$$: (Text "o = " :<>: ShowType o)) 

type family ThisT lr where ... Source #

Equations

ThisT (These a b) = a 
ThisT o = TypeError (Text "ThisT: expected 'These a b' " :$$: (Text "o = " :<>: ShowType o)) 

type family ThatT lr where ... Source #

Equations

ThatT (These a b) = b 
ThatT o = TypeError (Text "ThatT: expected 'These a b' " :$$: (Text "o = " :<>: ShowType o)) 

type family TheseT lr where ... Source #

Equations

TheseT (These a b) = (a, b) 
TheseT o = TypeError (Text "TheseT: expected 'These a b' " :$$: (Text "o = " :<>: ShowType o)) 

extract values from the type level

nat :: forall n a. (KnownNat n, Num a) => a Source #

get a Nat from the typelevel

>>> nat @14
14

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]

Methods

getNats :: [Int] Source #

Instances
GetNats ([] :: [k]) Source # 
Instance details

Defined in Predicate.Util

Methods

getNats :: [Int] Source #

(KnownNat n, GetNats ns) => GetNats (n ': ns :: [Nat]) Source # 
Instance details

Defined in Predicate.Util

Methods

getNats :: [Int] Source #

class GetSymbs ns where Source #

get a list of Symbols from the typelevel

>>> getSymbs @'["abc","def","g"]
["abc","def","g"]

Methods

getSymbs :: [String] Source #

Instances
GetSymbs ([] :: [k]) Source # 
Instance details

Defined in Predicate.Util

Methods

getSymbs :: [String] Source #

(KnownSymbol s, GetSymbs ss) => GetSymbs (s ': ss :: [Symbol]) Source # 
Instance details

Defined in Predicate.Util

Methods

getSymbs :: [String] Source #

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

Methods

getLen :: Int Source #

Instances
GetLen ([] :: [k]) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

GetLen (Nothing :: Maybe a) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

GetLen (Just a2 :: Maybe a1) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

GetLen xs => GetLen (x ': xs :: [a]) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

GetLen xs => GetLen (x :| xs :: NonEmpty a) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

GetLen (Right a2 :: Either a1 b) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

GetLen (Left a2 :: Either a1 b) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

GetLen (That a2 :: These a1 b) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

GetLen (This a2 :: These a1 b) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

GetLen (These a2 b2 :: These a1 b1) Source # 
Instance details

Defined in Predicate.Util

Methods

getLen :: Int Source #

class GetThese th where Source #

get These from typelevel

Methods

getThese :: (String, These w v -> Bool) Source #

Instances
GetThese (That y :: These a b) Source # 
Instance details

Defined in Predicate.Util

Methods

getThese :: (String, These w v -> Bool) Source #

GetThese (This x :: These a b) Source # 
Instance details

Defined in Predicate.Util

Methods

getThese :: (String, These w v -> Bool) Source #

GetThese (These x y :: These a b) Source # 
Instance details

Defined in Predicate.Util

Methods

getThese :: (String, These w v -> Bool) Source #

class GetOrdering (cmp :: Ordering) where Source #

get ordering from the typelevel

Instances
GetOrdering LT Source # 
Instance details

Defined in Predicate.Util

GetOrdering EQ Source # 
Instance details

Defined in Predicate.Util

GetOrdering GT Source # 
Instance details

Defined in Predicate.Util

class GetBool (a :: Bool) where Source #

get Bool from the typelevel

Methods

getBool :: Bool Source #

Instances
GetBool False Source # 
Instance details

Defined in Predicate.Util

Methods

getBool :: Bool Source #

GetBool True Source # 
Instance details

Defined in Predicate.Util

Methods

getBool :: Bool Source #

data OrderingP Source #

all the ways to compare two values

Constructors

CGt 
CGe 
CEq 
CLe 
CLt 
CNe 

class GetOrd (k :: OrderingP) where Source #

extract OrderingP from the typelevel

Methods

getOrd :: Ord a => (String, a -> a -> Bool) Source #

Instances
GetOrd CGt Source # 
Instance details

Defined in Predicate.Util

Methods

getOrd :: Ord a => (String, a -> a -> Bool) Source #

GetOrd CGe Source # 
Instance details

Defined in Predicate.Util

Methods

getOrd :: Ord a => (String, a -> a -> Bool) Source #

GetOrd CEq Source # 
Instance details

Defined in Predicate.Util

Methods

getOrd :: Ord a => (String, a -> a -> Bool) Source #

GetOrd CLe Source # 
Instance details

Defined in Predicate.Util

Methods

getOrd :: Ord a => (String, a -> a -> Bool) Source #

GetOrd CLt Source # 
Instance details

Defined in Predicate.Util

Methods

getOrd :: Ord a => (String, a -> a -> Bool) Source #

GetOrd CNe Source # 
Instance details

Defined in Predicate.Util

Methods

getOrd :: Ord a => (String, a -> a -> Bool) Source #

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 #

boolean methods

(~>) :: Bool -> Bool -> Bool infixr 1 Source #

boolean implication

>>> True ~> False
False
>>> True ~> True
True
>>> False ~> False
True
>>> False ~> True
True

extract from n-tuple

type family T4_1 x where ... Source #

extract 'opts' part of 4 tuple from the type level for use with Refined2

Equations

T4_1 '(opts, _, _, _) = opts 

type family T4_2 x where ... Source #

extract 'ip' part of 4 tuple from the type level for use with Refined2

Equations

T4_2 '(_, ip, _, _) = ip 

type family T4_3 x where ... Source #

extract 'op' part of 4 tuple from the type level for use with Refined2

Equations

T4_3 '(_, _, op, _) = op 

type family T4_4 x where ... Source #

extract 'i' part of 4 tuple from the type level for use with Refined2

Equations

T4_4 '(_, _, _, i) = i 

type family T5_1 x where ... Source #

extract 'opts' part of 5 tuple from the type level for use with Refined3

Equations

T5_1 '(opts, _, _, _, _) = opts 

type family T5_2 x where ... Source #

extract 'ip' part of 5 tuple from the type level for use with Refined3

Equations

T5_2 '(_, ip, _, _, _) = ip 

type family T5_3 x where ... Source #

extract 'op' part of 5 tuple from the type level for use with Refined3

Equations

T5_3 '(_, _, op, _, _) = op 

type family T5_4 x where ... Source #

extract 'fmt' part of 5 tuple from the type level for use with Refined3

Equations

T5_4 '(_, _, _, fmt, _) = fmt 

type family T5_5 x where ... Source #

extract 'i' part of 5 tuple from the type level for use with Refined3

Equations

T5_5 '(_, _, _, _, i) = i 

miscellaneous

data Holder Source #

a monomorphic container of trees

hh :: TT w -> Holder Source #

convenience method to wrap a typed tree

showT :: forall (t :: Type). Typeable t => String Source #

show the type as a string

showTK :: forall r. Typeable r => String Source #

show the kind as a string

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

Methods

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 #

liftEval :: m a -> IO a Source #

Instances
MonadEval IO Source #

IO instance for evaluating the expression

Instance details

Defined in Predicate.Util

Methods

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

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

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

liftEval :: IO a -> IO a Source #

MonadEval Identity Source #

Identity instance for evaluating the expression

Instance details

Defined in Predicate.Util

readField :: String -> ReadPrec a -> ReadPrec a Source #

read a field and value using ReadPrec parser

showThese :: These a b -> String Source #

display constructor name for These

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

deal with possible recursion on a list

pureTryTest :: a -> IO (Either () a) Source #

isPrime :: Int -> Bool Source #

prime predicate

>>> isPrime 7
True
>>> isPrime 6
False

unlessNull :: (Foldable t, Monoid m) => t a -> m -> m Source #

convenience method for optional display

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

message to display when the length of a foldable is exceeded

showIndex :: (Show i, Num i) => i -> String Source #