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

Safe HaskellNone
LanguageHaskell2010

Predicate.Data.Lifted

Contents

Description

lifted promoted functions

Synopsis

functor

data FMap p #

similar to <$>

>>> pl @(FMap Succ) (Right 'a')
Present Right 'b' (FMap Succ 'b' | 'a')
Val (Right 'b')
>>> pl @(FMap Succ) (Left "Sf")
Present Left "Sf" (FMap <skipped>)
Val (Left "Sf")
>>> pz @(FMap (MkDay Id) >> Join) (Just (2020,01,01))
Val (Just 2020-01-01)
>>> pz @(FMap (MkDay Id) >> Join) (Just (2020,01,32))
Val Nothing
>>> pz @(FMap Succ) (Just LT)
Val (Just EQ)
>>> pz @(FMap Pred) (Just LT)
Fail "Pred IO e=Prelude.Enum.Ordering.pred: bad argument"
>>> pz @(FMap (ShowP Id)) (Just 10)
Val (Just "10")
>>> pan @(FMap $ FMap $ FMap Succ) [Just "abcdefG",Nothing,Just "X"]
P FMap FMap FMap Succ 'b' | Succ 'c' | Succ 'd' | Succ 'e' | Succ 'f' | Succ 'g' | Succ 'H' | FMap <skipped> | FMap FMap Succ 'Y'
|
+- P FMap FMap Succ 'b' | Succ 'c' | Succ 'd' | Succ 'e' | Succ 'f' | Succ 'g' | Succ 'H'
|  |
|  `- P FMap Succ 'b' | Succ 'c' | Succ 'd' | Succ 'e' | Succ 'f' | Succ 'g' | Succ 'H'
|     |
|     +- P Succ 'b'
|     |
|     +- P Succ 'c'
|     |
|     +- P Succ 'd'
|     |
|     +- P Succ 'e'
|     |
|     +- P Succ 'f'
|     |
|     +- P Succ 'g'
|     |
|     `- P Succ 'H'
|
+- P FMap <skipped>
|
`- P FMap FMap Succ 'Y'
   |
   `- P FMap Succ 'Y'
      |
      `- P Succ 'Y'
Val [Just "bcdefgH",Nothing,Just "Y"]
>>> pan @(FMap (FromEnum > 97)) "abc"
P FMap 97 > 97 | 98 > 97 | 99 > 97
|
+- False 97 > 97
|  |
|  +- P FromEnum 97
|  |
|  `- P '97
|
+- True 98 > 97
|  |
|  +- P FromEnum 98
|  |
|  `- P '97
|
`- True 99 > 97
   |
   +- P FromEnum 99
   |
   `- P '97
Val [False,True,True]
>>> pan @(FMap (FromEnum > 97 >> Id)) "abc"
P FMap (>>) False | (>>) True | (>>) True
|
+- P (>>) False
|  |
|  +- False 97 > 97
|  |  |
|  |  +- P FromEnum 97
|  |  |
|  |  `- P '97
|  |
|  `- P Id False
|
+- P (>>) True
|  |
|  +- True 98 > 97
|  |  |
|  |  +- P FromEnum 98
|  |  |
|  |  `- P '97
|  |
|  `- P Id True
|
`- P (>>) True
   |
   +- True 99 > 97
   |  |
   |  +- P FromEnum 99
   |  |
   |  `- P '97
   |
   `- P Id True
Val [False,True,True]
>>> pan @(FMap IdBool) (Just True)
P FMap IdBool
|
`- True IdBool
Val (Just True)
>>> pz @(FMap (Pure (Either String) Id)) [1,2,4]
Val [Right 1,Right 2,Right 4]
>>> pl @(FMap (Pure [] Id)) (Just 10)
Present Just [10] (FMap Pure [10] | 10)
Val (Just [10])
>>> pl @(FMap (Pure SG.Sum Id)) (Just 20)
Present Just (Sum {getSum = 20}) (FMap Pure Sum {getSum = 20} | 20)
Val (Just (Sum {getSum = 20}))
>>> pz @(FMap (Coerce (SG.Sum Integer))) [Identity (-13), Identity 4, Identity 99]
Val [Sum {getSum = -13},Sum {getSum = 4},Sum {getSum = 99}]
>>> pz @(FMap (Coerce (SG.Sum Integer))) (Just (Identity (-13)))
Val (Just (Sum {getSum = -13}))
>>> pz @(FMap (Coerce (SG.Sum Int))) (Nothing @(Identity Int))
Val Nothing
>>> pl @(FMap (Coerce (SG.Sum Int))) (Just (10 :: Int))
Present Just (Sum {getSum = 10}) (FMap Coerce Sum {getSum = 10} | 10)
Val (Just (Sum {getSum = 10}))
>>> pz @(Proxy Char >> FMap Succ) () ^!? acts . _Val . to typeRep
Just Char
Instances
(Traversable n, P p a) => P (FMap p :: Type) (n a) # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (FMap p) (n a) :: Type #

Methods

eval :: MonadEval m => proxy (FMap p) -> POpts -> n a -> m (TT (PP (FMap p) (n a))) #

Show (FMap p) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> FMap p -> ShowS #

show :: FMap p -> String #

showList :: [FMap p] -> ShowS #

type PP (FMap p :: Type) (n a) # 
Instance details

Defined in Predicate.Data.Lifted

type PP (FMap p :: Type) (n a) = n (PP p a)

data p <$> q infixl 4 #

similar to <$>

>>> pz @(Len <$> Snd) (1,Just "abcdef")
Val (Just 6)
>>> pz @(Len <$> (Id <> Id <> "extra" <$> Snd)) (1,Just "abcdef")
Val (Just 17)
>>> pz @(Len <$> (Id <> Id <> "extra" <$> Snd)) (1,Right "abcdef")
Val (Right 17)
>>> pz @(FMap $ FMap (Succ <$> Id)) (True,Just (These 12 'c'))
Val (True,Just (These 12 'd'))
>>> pz @(FMap (Second (Succ <$> Id))) [(True, (These 12 'c'))]
Val [(True,These 12 'd')]
Instances
(Traversable n, P q a, P p b, PP q a ~ n b, PP p b ~ c) => P (p <$> q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <$> q) a :: Type #

Methods

eval :: MonadEval m => proxy (p <$> q) -> POpts -> a -> m (TT (PP (p <$> q) a)) #

Show (p <$> q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p <$> q) -> ShowS #

show :: (p <$> q) -> String #

showList :: [p <$> q] -> ShowS #

type PP (p <$> q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p <$> q :: Type) a = ExtractTFromTA (PP q a) (PP p (ExtractAFromTA (PP q a)))

data p <&> q infixl 1 #

similar to <&>

>>> pz @('[1,2,3] <&> Succ) ()
Val [2,3,4]
Instances
P (FMapFlipT p q) x => P (p <&> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <&> q) x :: Type #

Methods

eval :: MonadEval m => proxy (p <&> q) -> POpts -> x -> m (TT (PP (p <&> q) x)) #

Show (p <&> q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p <&> q) -> ShowS #

show :: (p <&> q) -> String #

showList :: [p <&> q] -> ShowS #

type PP (p <&> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p <&> q :: Type) x

applicative

data p <*> q infixl 1 #

applicative bind similar to <*> but functions have to be fully saturated: ie Len is ok but not Length can use Proxy to delay evaluation until Pop0

>>> pz @(MkJust '("sdf",Id) <*> MkJust 4) ()
Val (Just ("sdf",4))
>>> pz @(MkJust Succ <*> MkJust 4) ()
Val (Just 5)
>>> pz @('[Succ,Id,Pred] <*> "abcdef") undefined
Val "ba`cbadcbedcfedgfe"
>>> pz @(MkJust "abc" <*> MkJust "def") () -- no function to apply so has to choose ie first one
Val (Just "abc")
>>> pz @('[1,2] <*> "abcdef") () -- [1,2] <* "abcdef" -- ie skips rhs "abcdef" but still runs the effects
Val [1,2,1,2,1,2,1,2,1,2,1,2]
>>> pz @(MkJust ((*) 3 Id) <*> MkJust 4) ()
Val (Just 12)
>>> pz @(MkJust ((*) 3 Len) <*> MkJust '["aa","bb","c","d","e"]) ()
Val (Just 15)
>>> pz @(ShowP Id <$> MkJust Succ <*> MkJust 4) ()
Val (Just "5")
>>> pz @('["x","y"] <*> '[1,2,3]) ()
Val ["x","y","x","y","x","y"]
Instances
P (AppT p q) x => P (p <*> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <*> q) x :: Type #

Methods

eval :: MonadEval m => proxy (p <*> q) -> POpts -> x -> m (TT (PP (p <*> q) x)) #

Show (p <*> q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p <*> q) -> ShowS #

show :: (p <*> q) -> String #

showList :: [p <*> q] -> ShowS #

type PP (p <*> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p <*> q :: Type) x

data LiftA2 p q r #

similar to liftA2

>>> pan @(LiftA2 Id (MkJust 12) (MkJust "abc")) ()
P LiftA2 Id (12,"abc")
|
+- P MkJust Just 12
|  |
|  `- P '12
|
+- P MkJust Just "abc"
|  |
|  `- P '"abc"
|
`- P Id (12,"abc")
Val (Just (12,"abc"))
>>> pan @(LiftA2 Swap (MkJust 12) (MkNothing _)) ()
P LiftA2 <skipped>
|
+- P MkJust Just 12
|  |
|  `- P '12
|
`- P MkNothing
Val Nothing
>>> pz @(LiftA2 (ShowP Fst <> "---" <> ShowP Snd) Fst Snd) (Just 10, Just True)
Val (Just "10---True")
>>> pz @(LiftA2 (Fst + Snd) Fst Snd) (Just 10, Just 13)
Val (Just 23)
>>> pz @(LiftA2 Fst '["x","y"] '[1,2,3]) ()
Val ["x","x","x","y","y","y"]
>>> pz @(LiftA2 Snd '["x","y"] '[1,2,3]) ()
Val [1,2,3,1,2,3]
>>> pz @(LiftA2 (Pop0 Fst Snd) '[ Proxy Len ] '[ "abc", "def", "aaaaaaaaaaa"]) ()
Val [3,3,11]
>>> pz @(LiftA2 (Fst * Snd) (FromList (ZipList _) << (10...15)) (FromList (ZipList _) << (1...10))) ()
Val (ZipList {getZipList = [10,22,36,52,70,90]})
Instances
(Traversable n, Applicative n, P p (a, b), P q x, P r x, PP p (a, b) ~ c, PP q x ~ n a, PP r x ~ n b) => P (LiftA2 p q r :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (LiftA2 p q r) x :: Type #

Methods

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

Show (LiftA2 p q r) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> LiftA2 p q r -> ShowS #

show :: LiftA2 p q r -> String #

showList :: [LiftA2 p q r] -> ShowS #

type PP (LiftA2 p q r :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (LiftA2 p q r :: Type) x = ExtractTFromTA (PP q x) (PP p (ExtractAFromTA (PP q x), ExtractAFromTA (PP r x)))

data FPair p q #

runs liftA2 (,) against two values: LiftA2 is traversable and provides better debugging

>>> pz @(FPair Fst Snd) (Just 10, Just True)
Val (Just (10,True))
>>> pz @(FPair Fst Snd >> FMap (ShowP Fst <> "---" <> ShowP Snd)) (Just 10, Just True)
Val (Just "10---True")
>>> pz @(FPair Fst Snd >> FMap (Fst + Snd)) (Just 10, Just 13)
Val (Just 23)
>>> pz @(FPair (EnumFromTo Fst Snd) ('LT ... 'GT) ) (10,11)
Val [(10,LT),(10,EQ),(10,GT),(11,LT),(11,EQ),(11,GT)]
Instances
(Applicative n, PP p a ~ n x, PP q a ~ n y, JoinT (PP p a) (PP q a) ~ n (x, y), P p a, P q a) => P (FPair p q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (FPair p q) a :: Type #

Methods

eval :: MonadEval m => proxy (FPair p q) -> POpts -> a -> m (TT (PP (FPair p q) a)) #

Show (FPair p q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> FPair p q -> ShowS #

show :: FPair p q -> String #

showList :: [FPair p q] -> ShowS #

type PP (FPair p q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

type PP (FPair p q :: Type) a = JoinT (PP p a) (PP q a)

data p <:> q infixl 6 #

see FPair

>>> pz @(Fst <:> Snd) (Just 10, Just True)
Val (Just (10,True))
>>> pz @(Fst <:> Snd) ("abc",[10,12,14])
Val [('a',10),('a',12),('a',14),('b',10),('b',12),('b',14),('c',10),('c',12),('c',14)]
>>> pz @('[1,2] <:> "abcdef") ()
Val [(1,'a'),(1,'b'),(1,'c'),(1,'d'),(1,'e'),(1,'f'),(2,'a'),(2,'b'),(2,'c'),(2,'d'),(2,'e'),(2,'f')]
>>> pz @(EnumFromTo Fst Snd <:> ('LT ... 'GT)) (10,11)
Val [(10,LT),(10,EQ),(10,GT),(11,LT),(11,EQ),(11,GT)]
>>> pz @(MkJust Succ <:> MkJust 4) ()   -- uses Succ on (): instead use LiftA2 with Pop0 or <*>  (see next 2 tests)
Fail "Succ IO e=Prelude.Enum.().succ: bad argument"
>>> pz @(LiftA2 (Pop0 Fst Snd) (MkJust (Proxy Succ)) (MkJust 4)) ()
Val (Just 5)
>>> pz @(MkJust Succ <*> MkJust 4) ()
Val (Just 5)
Instances
P (FPairT p q) x => P (p <:> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <:> q) x :: Type #

Methods

eval :: MonadEval m => proxy (p <:> q) -> POpts -> x -> m (TT (PP (p <:> q) x)) #

Show (p <:> q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p <:> q) -> ShowS #

show :: (p <:> q) -> String #

showList :: [p <:> q] -> ShowS #

type PP (p <:> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p <:> q :: Type) x

data p <$ q infixl 4 #

similar to <$

>>> pz @(Fst <$ Snd) ("abc",Just 20)
Val (Just "abc")
>>> pl @(Fst <$ Snd) (4,These "xxx" 'a')
Present These "xxx" 4 ((<$) 4)
Val (These "xxx" 4)
>>> pl @(Fst <$ Snd) (4,This 'a')
Present This 'a' ((<$) 4)
Val (This 'a')
>>> pl @(Fst <$ Snd) (4,Just 'a')
Present Just 4 ((<$) 4)
Val (Just 4)
>>> pl @(Fst <$ Snd) (4,Nothing @Int)
Present Nothing ((<$) 4)
Val Nothing
>>> pl @('True <$ Id) [1..4]
Present [True,True,True,True] ((<$) True)
Val [True,True,True,True]
>>> import Data.Functor.Compose
>>> pl @(C "ab" <$ Id) (Compose $ Just [1..4])
Present Compose (Just "aaaa") ((<$) 'a')
Val (Compose (Just "aaaa"))
>>> pl @(Snd <$ Fst) (Just 10,'x')
Present Just 'x' ((<$) 'x')
Val (Just 'x')
Instances
(P p x, P q x, Show (PP p x), Functor t, PP q x ~ t c, ApplyConstT (PP q x) (PP p x) ~ t (PP p x)) => P (p <$ q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <$ q) x :: Type #

Methods

eval :: MonadEval m => proxy (p <$ q) -> POpts -> x -> m (TT (PP (p <$ q) x)) #

Show (p <$ q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p <$ q) -> ShowS #

show :: (p <$ q) -> String #

showList :: [p <$ q] -> ShowS #

type PP (p <$ q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p <$ q :: Type) x = ApplyConstT (PP q x) (PP p x)

data p <* q infixl 4 #

similar to Applicative <*

>>> pl @(Fst <* Snd) (Just 4,Just 'a')
Present Just 4 ((<*) Just 4 | p=Just 4 | q=Just 'a')
Val (Just 4)
>>> pz @(Fst <* Snd) (Just "abc",Just 20)
Val (Just "abc")
>>> pz @('["x","y"] <* '[1,2,3]) ()
Val ["x","x","x","y","y","y"]
Instances
(P p x, P q x, Show (t b), Show (t c), Applicative t, PP p x ~ t b, PP q x ~ t c) => P (p <* q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <* q) x :: Type #

Methods

eval :: MonadEval m => proxy (p <* q) -> POpts -> x -> m (TT (PP (p <* q) x)) #

Show (p <* q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p <* q) -> ShowS #

show :: (p <* q) -> String #

showList :: [p <* q] -> ShowS #

type PP (p <* q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p <* q :: Type) x = PP p x

data p *> q infixl 4 #

similar to Applicative *>

>>> pl @(Fst *> Snd) (Just 4,Just 'a')
Present Just 'a' ((*>) Just 4 | p=Just 4 | q=Just 'a')
Val (Just 'a')
>>> pz @('["x","y"] *> '[1,2,3]) ()
Val [1,2,3,1,2,3]
Instances
(P p x, P q x, Show (t b), Show (t c), Applicative t, PP p x ~ t b, PP q x ~ t c) => P (p *> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p *> q) x :: Type #

Methods

eval :: MonadEval m => proxy (p *> q) -> POpts -> x -> m (TT (PP (p *> q) x)) #

Show (p *> q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p *> q) -> ShowS #

show :: (p *> q) -> String #

showList :: [p *> q] -> ShowS #

type PP (p *> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p *> q :: Type) x = PP q x

monad

data FFish amb bmc a #

similar to monad operator >=>

>>> pz @(FFish Uncons (Snd >> Uncons) "abcdef") ()
Val (Just ('b',"cdef"))
>>> :m + Data.Time
>>> pz @(FFish (ReadMaybe Day Id >> FMap Fst) (MkJust Succ) "2020-02-02") ()
Val (Just 2020-02-03)
>>> pz @(FFish Uncons (Lookup Fst "abcdef") [3,14,12]) ()
Val (Just 'd')
Instances
P (FFishT p q r) x => P (FFish p q r :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (FFish p q r) x :: Type #

Methods

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

Show (FFish amb bmc a) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> FFish amb bmc a -> ShowS #

show :: FFish amb bmc a -> String #

showList :: [FFish amb bmc a] -> ShowS #

type PP (FFish p q r :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (FFish p q r :: Type) x

data ma >>= amb infixl 1 #

similar to monad bind operator >>=

>>> pz @(Id >>= HeadMay) (Just "abcdef")
Val (Just 'a')
>>> pz @(Uncons >>= (Snd >> HeadMay)) "abcdef"
Val (Just 'b')
>>> pz @((1 ... 10) >>= EmptyBool [] Even '[Id,Id]) ()
Val [[2,2],[4,4],[6,6],[8,8],[10,10]]
>>> pz @( (1 ... 10) >>= If Even '[Id,Id] (EmptyT [])) ()
Val [2,2,4,4,6,6,8,8,10,10]
>>> pz @(Lookup 0 Id >>= Lookup 1 Id) [[1,2,3]]
Val (Just 2)
>>> pz @(Lookup 4 Id >>= Lookup 1 Id) [[1,2,3]]
Val Nothing
>>> pz @(Lookup 0 Id >>= Lookup 5 Id) [[1,2,3]]
Val Nothing
>>> pz @(Lookup 0 Id >>= Lookup 1 Id >>= MaybeBool Even '(Id,"is even!")) [[1,2,3]]
Val (Just (2,"is even!"))
>>> pz @(Lookup 0 Id >>= Lookup 1 Id >>= MaybeBool Even '(Id,"is even!")) [[1,5,3]]
Val Nothing
>>> pz @((48...55) >>= '[ '[ToEnum Char << Id,ToEnum Char << (Id+3),ToEnum Char << (Id+6)] ]) ()
Val ["036","147","258","369","47:","58;","69<","7:="]
>>> pz @((48...55) >>= '[ Map (ToEnum Char) << '[ Id, Id+3 ,Id+6 ] ]) ()
Val ["036","147","258","369","47:","58;","69<","7:="]
Instances
P (MBindT p q) x => P (p >>= q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p >>= q) x :: Type #

Methods

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

Show (ma >>= amb) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (ma >>= amb) -> ShowS #

show :: (ma >>= amb) -> String #

showList :: [ma >>= amb] -> ShowS #

type PP (p >>= q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p >>= q :: Type) x

data Sequence #

similar to sequenceA

>>> pz @Sequence [Just 10, Just 20, Just 30]
Val (Just [10,20,30])
>>> pz @Sequence [Just 10, Just 20, Just 30, Nothing, Just 40]
Val Nothing
Instances
Show Sequence # 
Instance details

Defined in Predicate.Data.Lifted

(Show (f (t a)), Show (t (f a)), Traversable t, Applicative f) => P Sequence (t (f a)) # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP Sequence (t (f a)) :: Type #

Methods

eval :: MonadEval m => proxy Sequence -> POpts -> t (f a) -> m (TT (PP Sequence (t (f a)))) #

type PP Sequence (t (f a)) # 
Instance details

Defined in Predicate.Data.Lifted

type PP Sequence (t (f a)) = f (t a)

data Traverse p #

like traverse

>>> pl @(Traverse (If (Gt 3) (Pure Maybe Id) (EmptyT Maybe))) [1..5]
Present Nothing ((>>) Nothing | {Sequence Nothing | [Nothing,Nothing,Nothing,Just 4,Just 5]})
Val Nothing
>>> pl @(Traverse (MaybeBool (Le 3) Id)) [1..5]
Present Nothing ((>>) Nothing | {Sequence Nothing | [Just 1,Just 2,Just 3,Nothing,Nothing]})
Val Nothing
>>> pl @(Traverse (If (Gt 0) (Pure Maybe Id) (EmptyT Maybe))) [1..5]
Present Just [1,2,3,4,5] ((>>) Just [1,2,3,4,5] | {Sequence Just [1,2,3,4,5] | [Just 1,Just 2,Just 3,Just 4,Just 5]})
Val (Just [1,2,3,4,5])
>>> pl @(Traverse (If (Gt 0) (Pure Maybe Id) (MkNothing _))) [1..5]
Present Just [1,2,3,4,5] ((>>) Just [1,2,3,4,5] | {Sequence Just [1,2,3,4,5] | [Just 1,Just 2,Just 3,Just 4,Just 5]})
Val (Just [1,2,3,4,5])
>>> pl @(Traverse (MaybeBool (Id >= 0) Id)) [1..5]
Present Just [1,2,3,4,5] ((>>) Just [1,2,3,4,5] | {Sequence Just [1,2,3,4,5] | [Just 1,Just 2,Just 3,Just 4,Just 5]})
Val (Just [1,2,3,4,5])
>>> pl @(Traverse (MaybeBool (Id <= 3) Id)) [1..5]
Present Nothing ((>>) Nothing | {Sequence Nothing | [Just 1,Just 2,Just 3,Nothing,Nothing]})
Val Nothing
Instances
P (TraverseT p) x => P (Traverse p :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Traverse p) x :: Type #

Methods

eval :: MonadEval m => proxy (Traverse p) -> POpts -> x -> m (TT (PP (Traverse p) x)) #

Show (Traverse p) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Traverse p -> ShowS #

show :: Traverse p -> String #

showList :: [Traverse p] -> ShowS #

type PP (Traverse p :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Traverse p :: Type) x

data Join #

similar to join

>>> pz @Join (Just (Just 20))
Val (Just 20)
>>> pz @Join ["ab","cd","","ef"]
Val "abcdef"
Instances
Show Join # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Join -> ShowS #

show :: Join -> String #

showList :: [Join] -> ShowS #

(Show (t (t a)), Show (t a), Monad t) => P Join (t (t a)) # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP Join (t (t a)) :: Type #

Methods

eval :: MonadEval m => proxy Join -> POpts -> t (t a) -> m (TT (PP Join (t (t a)))) #

type PP Join (t (t a)) # 
Instance details

Defined in Predicate.Data.Lifted

type PP Join (t (t a)) = t a

alternative

data p <|> q infixl 3 #

similar to <|>

>>> pz @(Fst <|> Snd) (Nothing,Just 20)
Val (Just 20)
>>> pz @(Fst <|> Snd) (Just 10,Just 20)
Val (Just 10)
>>> pz @(Fst <|> Snd) (Nothing,Nothing)
Val Nothing
>>> pl @(Fst <|> Snd) (Just "cdef",Just "ab")
Present Just "cdef" ((<|>) Just "cdef" | p=Just "cdef" | q=Just "ab")
Val (Just "cdef")
>>> pl @(Fst <|> Snd) ("cdef","ab"::String)
Present "cdefab" ((<|>) "cdefab" | p="cdef" | q="ab")
Val "cdefab"
Instances
(P p x, P q x, Show (t b), Alternative t, t b ~ PP p x, PP q x ~ t b) => P (p <|> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <|> q) x :: Type #

Methods

eval :: MonadEval m => proxy (p <|> q) -> POpts -> x -> m (TT (PP (p <|> q) x)) #

Show (p <|> q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p <|> q) -> ShowS #

show :: (p <|> q) -> String #

showList :: [p <|> q] -> ShowS #

type PP (p <|> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p <|> q :: Type) x = PP p x

bifunctor

data BiMap p q #

similar to bimap

>>> pz @(BiMap Succ Head) (Left @_ @String 12) -- needs a type signature for Right
Val (Left 13)
>>> pz @(BiMap Succ Head) (Right "xyz")
Val (Right 'x')
>>> pz @(FMap (BiMap Succ Head)) [Right "xyz",Left 'a',Right "ab",Left 'x']
Val [Right 'x',Left 'b',Right 'a',Left 'y']
>>> pz @(FMap (BiMap Succ Pred)) [These 12 'b', This 1, That 'd',That 'e']
Val [These 13 'a',This 2,That 'c',That 'd']
>>> pz @(BiMap Succ Pred) (True,12,'b')
Val (True,13,'a')
>>> pl @(FMap $ BiMap Succ (Not Id)) [This @Int @Bool 1, This 2,That True,These 4 False]
Present [This 2,This 3,That False,These 5 True] (FMap BiMap(L) Succ 2 | 1 | BiMap(L) Succ 3 | 2 | BiMap(R) Not (Id True) | BiMap(B) Succ 5 | 4 | Not (Id False))
Val [This 2,This 3,That False,These 5 True]
>>> pl @(BiMap Succ (Not Id)) (This @Int @Bool 1)
Present This 2 (BiMap(L) Succ 2 | 1)
Val (This 2)
>>> pl @(BiMap Succ (Not Id)) (That @Int @Bool True)
Present That False (BiMap(R) Not (Id True))
Val (That False)
>>> pl @(BiMap Succ (Not Id)) (These @Int @Bool 1 True)
Present These 2 False (BiMap(B) Succ 2 | 1 | Not (Id True))
Val (These 2 False)
>>> pan @(FMap $ BiMap Succ (Not Id)) [This @Int @Bool 1, This 2,That True,These 4 False]
P FMap BiMap(L) Succ 2 | BiMap(L) Succ 3 | BiMap(R) Not | BiMap(B) Succ 5 | Not
|
+- P BiMap(L) Succ 2
|  |
|  `- P Succ 2
|
+- P BiMap(L) Succ 3
|  |
|  `- P Succ 3
|
+- P BiMap(R) Not
|  |
|  `- False Not
|     |
|     `- True Id True
|
`- P BiMap(B) Succ 5 | Not
   |
   +- P Succ 5
   |
   `- True Not
      |
      `- False Id False
Val [This 2,This 3,That False,These 5 True]
>>> pl @(BiMap Succ Head) (EEmpty @Int @String)
Present EEmpty (BiMap <skipped>)
Val EEmpty
>>> pl @(BiMap Succ Head) (ELeft @Int @String 10)
Present ELeft 11 (BiMap(L) Succ 11 | 10)
Val (ELeft 11)
>>> pl @(BiMap Succ Head) (ERight @Int @String "xyz")
Present ERight 'x' (BiMap(R) Head 'x' | "xyz")
Val (ERight 'x')
>>> pl @(BiMap Succ Head) (EBoth @Int @String 10 "xyz")
Present EBoth 11 'x' (BiMap(B) Succ 11 | 10 | Head 'x' | "xyz")
Val (EBoth 11 'x')
>>> pan @(FMap $ BiMap Succ Head) [EEmpty,ELeft 10,ERight "abc",EBoth 10 "xyz"]
P FMap BiMap <skipped> | BiMap(L) Succ 11 | BiMap(R) Head 'a' | BiMap(B) Succ 11 | Head 'x'
|
+- P BiMap <skipped>
|
+- P BiMap(L) Succ 11
|  |
|  `- P Succ 11
|
+- P BiMap(R) Head 'a'
|  |
|  `- P Head 'a'
|
`- P BiMap(B) Succ 11 | Head 'x'
   |
   +- P Succ 11
   |
   `- P Head 'x'
Val [EEmpty,ELeft 11,ERight 'a',EBoth 11 'x']
Instances
(Bitraversable n, P p a, P q b) => P (BiMap p q :: Type) (n a b) # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (BiMap p q) (n a b) :: Type #

Methods

eval :: MonadEval m => proxy (BiMap p q) -> POpts -> n a b -> m (TT (PP (BiMap p q) (n a b))) #

Show (BiMap p q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> BiMap p q -> ShowS #

show :: BiMap p q -> String #

showList :: [BiMap p q] -> ShowS #

type PP (BiMap p q :: Type) (n a b) # 
Instance details

Defined in Predicate.Data.Lifted

type PP (BiMap p q :: Type) (n a b) = n (PP p a) (PP q b)

comonad

data Extract #

similar to extract

>>> pz @Extract (Nothing,Just 20)
Val (Just 20)
>>> pz @Extract (Identity 20)
Val 20
>>> pl @Extract (10,"hello")
Present "hello" (Extract "hello" | (10,"hello"))
Val "hello"
Instances
Show Extract # 
Instance details

Defined in Predicate.Data.Lifted

(Show (t a), Show a, Comonad t) => P Extract (t a) # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP Extract (t a) :: Type #

Methods

eval :: MonadEval m => proxy Extract -> POpts -> t a -> m (TT (PP Extract (t a))) #

type PP Extract (t a) # 
Instance details

Defined in Predicate.Data.Lifted

type PP Extract (t a) = a

data Duplicate #

similar to duplicate

>>> pz @Duplicate (20,"abc")
Val (20,(20,"abc"))
Instances
Show Duplicate # 
Instance details

Defined in Predicate.Data.Lifted

(Show (t a), Show (t (t a)), Comonad t) => P Duplicate (t a) # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP Duplicate (t a) :: Type #

Methods

eval :: MonadEval m => proxy Duplicate -> POpts -> t a -> m (TT (PP Duplicate (t a))) #

type PP Duplicate (t a) # 
Instance details

Defined in Predicate.Data.Lifted

type PP Duplicate (t a) = t (t a)

function application

data p $$ q infixl 0 #

function application for pure functions appearing on the rhs: similar to $

>>> :m + Text.Show.Functions
>>> pz @(Fst $$ Snd) ((*16),4)
Val 64
>>> pz @(Id $$ "def") ("abc"<>)
Val "abcdef"
>>> pz @(Id $$ 12) (*13)
Val 156
>>> pz @(Id $$ 7 $$ 3) (*)
Val 21
>>> pz @(Id $$ 7 $$ 3) (,)
Val (7,3)
>>> pz @(Id $$ "abc" $$ 'True) (,)
Val ("abc",True)
>>> pz @(Id $$ "asdf" $$ 99 $$ C "A") (,,)
Val ("asdf",99,'A')
>>> (fmap.fmap) ($ 9999) $ pz @Id (*33)
Val 329967
>>> (fmap.fmap) ($ 9999) $ pz @(Id $$ 1 $$ 'True) (,,)
Val (1,True,9999)
>>> (fmap.fmap.fmap) ($ 8) $ pz @'("xxx",Id) (*33)
Val ("xxx",264)
>>> pz @('True $& 4 $& Id $$ "aa") (,,)
Val (4,True,"aa")
>>> pz @(Id $$ '(100,120)) (flip randomR (mkStdGen 7))
Val (114,320112 40692)
>>> pz @(Id $$ GenPure 12) (randomR ('a','f'))
Val ('f',520182 40692)
>>> pz @(Id $$ GenIO) (randomR ('a','f')) ^!? acts . _Val . _1 . nearly 'a' (`elem` ['a'..'f'])
Just ()
>>> pz @((Id $$ "abc" $$ Wrap (SG.Sum _) 14) >> Id <> Id) These
Val (These "abcabc" (Sum {getSum = 28}))
Instances
(P p x, P q x, PP p x ~ (a -> b), FnT (PP p x) ~ b, PP q x ~ a, Show a, Show b) => P (p $$ q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p $$ q) x :: Type #

Methods

eval :: MonadEval m => proxy (p $$ q) -> POpts -> x -> m (TT (PP (p $$ q) x)) #

Show (p $$ q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p $$ q) -> ShowS #

show :: (p $$ q) -> String #

showList :: [p $$ q] -> ShowS #

type PP (p $$ q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p $$ q :: Type) x = FnT (PP p x)

data q $& p infixr 1 #

flipped function application for expressions: similar to &

>>> :m + Text.Show.Functions
>>> pz @(Snd $& Fst) ((*16),4)
Val 64
>>> pz @("def" $& Id) ("abc"<>)
Val "abcdef"
>>> pz @('True $& 4 $& Id) (,)
Val (4,True)
Instances
(P p x, P q x, PP p x ~ (a -> b), FnT (PP p x) ~ b, PP q x ~ a, Show a, Show b) => P (q $& p :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (q $& p) x :: Type #

Methods

eval :: MonadEval m => proxy (q $& p) -> POpts -> x -> m (TT (PP (q $& p) x)) #

Show (q $& p) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (q $& p) -> ShowS #

show :: (q $& p) -> String #

showList :: [q $& p] -> ShowS #

type PP (q $& p :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (q $& p :: Type) x = FnT (PP p x)

data Skip p #

just run the effect ignoring the result passing the original value through

for example for use with Stdout so it doesnt interfere with the a on the rhs unless it fails

Instances
(Show (PP p a), P p a) => P (Skip p :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Skip p) a :: Type #

Methods

eval :: MonadEval m => proxy (Skip p) -> POpts -> a -> m (TT (PP (Skip p) a)) #

Show (Skip p) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Skip p -> ShowS #

show :: Skip p -> String #

showList :: [Skip p] -> ShowS #

type PP (Skip p :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Skip p :: Type) a = a

data p |> q infixr 1 #

run p for the effect and then run q using that original value

Instances
P (SkipLT p q) x => P (p |> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p |> q) x :: Type #

Methods

eval :: MonadEval m => proxy (p |> q) -> POpts -> x -> m (TT (PP (p |> q) x)) #

Show (p |> q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p |> q) -> ShowS #

show :: (p |> q) -> String #

showList :: [p |> q] -> ShowS #

type PP (p |> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p |> q :: Type) x

data p >| q infixr 1 #

run run p and then q for the effect but using the result from p

Instances
P (SkipRT p q) x => P (p >| q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p >| q) x :: Type #

Methods

eval :: MonadEval m => proxy (p >| q) -> POpts -> x -> m (TT (PP (p >| q) x)) #

Show (p >| q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p >| q) -> ShowS #

show :: (p >| q) -> String #

showList :: [p >| q] -> ShowS #

type PP (p >| q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p >| q :: Type) x

data p >|> q infixr 1 #

run both p and q for their effects but ignoring the results

Instances
P (SkipBothT p q) x => P (p >|> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p >|> q) x :: Type #

Methods

eval :: MonadEval m => proxy (p >|> q) -> POpts -> x -> m (TT (PP (p >|> q) x)) #

Show (p >|> q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> (p >|> q) -> ShowS #

show :: (p >|> q) -> String #

showList :: [p >|> q] -> ShowS #

type PP (p >|> q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (p >|> q :: Type) x

data Flip (p :: k1 -> k2 -> k3) (q :: k2) (r :: k1) #

similar to flip:see also FlipT

>>> pz @(Flip Map' Id Succ) [1..5]
Val [2,3,4,5,6]
>>> pz @( Flip '(,) 'True 2) ()
Val (2,True)
>>> pz @( Flip ('(,,) 1) 2 Id) "ab"
Val (1,"ab",2)
Instances
P (p r q) x => P (Flip p q r :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Flip p q r) x :: Type #

Methods

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

Show (Flip p q r) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Flip p q r -> ShowS #

show :: Flip p q r -> String #

showList :: [Flip p q r] -> ShowS #

type PP (Flip p q r :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Flip p q r :: Type) x = PP (p r q) x

data Dot (ps :: [Type -> Type]) (q :: Type) #

compose simple functions

>>> pl @(Dot '[L3,L2,L1] Id) ((1,(2,9,10)),(3,4))
Present 10 (Thd 10 | (2,9,10))
Val 10
Instances
P (DotExpandT ps q) a => P (Dot ps q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Dot ps q) a :: Type #

Methods

eval :: MonadEval m => proxy (Dot ps q) -> POpts -> a -> m (TT (PP (Dot ps q) a)) #

Show (Dot ps q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Dot ps q -> ShowS #

show :: Dot ps q -> String #

showList :: [Dot ps q] -> ShowS #

type PP (Dot ps q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Dot ps q :: Type) a

data RDot (ps :: [Type -> Type]) (q :: Type) #

reversed version of Dot

>>> pl @(RDot '[L1,L2,L3] Id) ((1,(2,9,10)),(3,4))
Present 10 (Thd 10 | (2,9,10))
Val 10
>>> pl @(RDot '[L1,L2] Id) (('a',2),(True,"zy"))
Present 2 (Snd 2 | ('a',2))
Val 2
Instances
P (RDotExpandT ps q) a => P (RDot ps q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (RDot ps q) a :: Type #

Methods

eval :: MonadEval m => proxy (RDot ps q) -> POpts -> a -> m (TT (PP (RDot ps q) a)) #

Show (RDot ps q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> RDot ps q -> ShowS #

show :: RDot ps q -> String #

showList :: [RDot ps q] -> ShowS #

type PP (RDot ps q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

type PP (RDot ps q :: Type) a

data K (p :: k) (q :: k1) #

similar to const:types dont need to match on rhs!

>>> pl @(RDot '[L1,L2,L3,K "xxx"] Id) 12345
Present "xxx" (K '"xxx")
Val "xxx"
>>> pl @(RDot '[L1,L2,L3,K '("abc",Id)] Id) ()
Present ("abc",()) (K '("abc",()))
Val ("abc",())
>>> pl @(Dot '[K "skip",L6,Lift Dup,Lift Succ] Id) ()
Present "skip" (K '"skip")
Val "skip"
>>> pl @(L3 $ L2 $ L1 $ K Id "dud") ((1,("X",9,'a')),(3,4))
Present 'a' (Thd 'a' | ("X",9,'a'))
Val 'a'
>>> pl @((L3 $ L2 $ L1 $ K Id "dud") >> Pred) ((1,("X",9,'a')),(3,4))
Present '`' ((>>) '`' | {Pred '`' | 'a'})
Val '`'
>>> pl @(K "ss" $ L3 $ L3 $ Fst) ()
Present "ss" (K '"ss")
Val "ss"
Instances
P p a => P (K p q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (K p q) a :: Type #

Methods

eval :: MonadEval m => proxy (K p q) -> POpts -> a -> m (TT (PP (K p q) a)) #

Show (K p q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> K p q -> ShowS #

show :: K p q -> String #

showList :: [K p q] -> ShowS #

type PP (K p q :: Type) a # 
Instance details

Defined in Predicate.Data.Lifted

type PP (K p q :: Type) a = PP p a

data Lift p q #

Lift a no arg Adt to a function of one argument (for use with Dot and RDot)

>>> pl @(Lift Len Snd) (True,"abcdef")
Present 6 ((>>) 6 | {Len 6 | "abcdef"})
Val 6
Instances
P (LiftT p q) x => P (Lift p q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Lift p q) x :: Type #

Methods

eval :: MonadEval m => proxy (Lift p q) -> POpts -> x -> m (TT (PP (Lift p q) x)) #

Show (Lift p q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Lift p q -> ShowS #

show :: Lift p q -> String #

showList :: [Lift p q] -> ShowS #

type PP (Lift p q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Lift p q :: Type) x

error handling

data Catch p q #

run an expression p and on failure run q

>>> pz @(Catch Succ (Fst >> Second (ShowP Id) >> PrintT "%s %s" Id >> 'LT)) GT
Val LT
>>> pz @(Len > 1 && Catch (Id !! 3 == 66) 'False) [1,2]
Val False
>>> pl @(Catch (Resplit "\\d+(") (Snd >> MEmptyP)) "123"
Present [] (Catch caught exception[Regex failed to compile])
Val []
>>> pl @(Catch OneP 99) [10,11]
Present 99 (Catch caught exception[OneP:expected one element(2)])
Val 99
>>> pl @(Catch OneP 99) [10]
Present 10 (Catch did not fire)
Val 10
>>> pl @(Catch OneP 'True) [False]
Present False (Catch did not fire)
Val False
>>> pl @(Catch OneP 'False) [True,True,False]
False (Catch caught exception[OneP:expected one element(3)])
Val False
>>> pl @(Catch OneP 'True) []
True (Catch caught exception[OneP:expected one element(empty)])
Val True
Instances
(P p x, P q ((String, x), Proxy (PP p x)), PP p x ~ PP q ((String, x), Proxy (PP p x))) => P (Catch p q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Catch p q) x :: Type #

Methods

eval :: MonadEval m => proxy (Catch p q) -> POpts -> x -> m (TT (PP (Catch p q) x)) #

Show (Catch p q) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Catch p q -> ShowS #

show :: Catch p q -> String #

showList :: [Catch p q] -> ShowS #

type PP (Catch p q :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Catch p q :: Type) x = PP p x

data Catch' p s #

run an expression p and on failure print a custom error s using the error string and the input value

>>> pz @(Catch' Succ (Second (ShowP Id) >> PrintT "%s %s" Id)) GT
Fail "Succ IO e=Prelude.Enum.Ordering.succ: bad argument GT"
>>> pz @(Catch' Succ (Second (ShowP Id) >> PrintT "%s %s" Id)) LT
Val EQ
>>> pl @(Catch' (FailT Int "someval") (PrintT "msg=%s caught(%03d)" Id)) 44
Error msg=someval caught(044) (Catch default condition failed)
Fail "msg=someval caught(044)"
>>> pl @(Catch' OneP (Second (ShowP Id) >> PrintT "msg=%s caught(%s)" Id)) [10,12,13]
Error msg=OneP:expected one element(3) caught([10,12,13]) (Catch default condition failed)
Fail "msg=OneP:expected one element(3) caught([10,12,13])"
>>> pl @(Catch' OneP (PrintT "msg=%s caught(%s)" (Second (ShowP Id)))) [10]
Present 10 (Catch did not fire)
Val 10
>>> pl @(Catch' OneP (PrintT "msg=%s err s=%s" (Second (ShowP Id)))) [10,11]
Error msg=OneP:expected one element(2) err s=[10,11] (Catch default condition failed)
Fail "msg=OneP:expected one element(2) err s=[10,11]"
Instances
P (CatchT' p s) x => P (Catch' p s :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Catch' p s) x :: Type #

Methods

eval :: MonadEval m => proxy (Catch' p s) -> POpts -> x -> m (TT (PP (Catch' p s) x)) #

Show (Catch' p s) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Catch' p s -> ShowS #

show :: Catch' p s -> String #

showList :: [Catch' p s] -> ShowS #

type PP (Catch' p s :: Type) x # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Catch' p s :: Type) x

miscellaneous

data ELR a b #

Constructors

EEmpty 
ELeft !a 
ERight !b 
EBoth !a !b 
Instances
Bitraversable ELR # 
Instance details

Defined in Predicate.Data.Lifted

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> ELR a b -> f (ELR c d) #

Bifoldable ELR # 
Instance details

Defined in Predicate.Data.Lifted

Methods

bifold :: Monoid m => ELR m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> ELR a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> ELR a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> ELR a b -> c #

Bifunctor ELR # 
Instance details

Defined in Predicate.Data.Lifted

Methods

bimap :: (a -> b) -> (c -> d) -> ELR a c -> ELR b d #

first :: (a -> b) -> ELR a c -> ELR b c #

second :: (b -> c) -> ELR a b -> ELR a c #

Functor (ELR a) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

fmap :: (a0 -> b) -> ELR a a0 -> ELR a b #

(<$) :: a0 -> ELR a b -> ELR a a0 #

Foldable (ELR a) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

fold :: Monoid m => ELR a m -> m #

foldMap :: Monoid m => (a0 -> m) -> ELR a a0 -> m #

foldr :: (a0 -> b -> b) -> b -> ELR a a0 -> b #

foldr' :: (a0 -> b -> b) -> b -> ELR a a0 -> b #

foldl :: (b -> a0 -> b) -> b -> ELR a a0 -> b #

foldl' :: (b -> a0 -> b) -> b -> ELR a a0 -> b #

foldr1 :: (a0 -> a0 -> a0) -> ELR a a0 -> a0 #

foldl1 :: (a0 -> a0 -> a0) -> ELR a a0 -> a0 #

toList :: ELR a a0 -> [a0] #

null :: ELR a a0 -> Bool #

length :: ELR a a0 -> Int #

elem :: Eq a0 => a0 -> ELR a a0 -> Bool #

maximum :: Ord a0 => ELR a a0 -> a0 #

minimum :: Ord a0 => ELR a a0 -> a0 #

sum :: Num a0 => ELR a a0 -> a0 #

product :: Num a0 => ELR a a0 -> a0 #

Traversable (ELR a) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

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

sequenceA :: Applicative f => ELR a (f a0) -> f (ELR a a0) #

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

sequence :: Monad m => ELR a (m a0) -> m (ELR a a0) #

(Eq a, Eq b) => Eq (ELR a b) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

(==) :: ELR a b -> ELR a b -> Bool #

(/=) :: ELR a b -> ELR a b -> Bool #

(Ord a, Ord b) => Ord (ELR a b) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

compare :: ELR a b -> ELR a b -> Ordering #

(<) :: ELR a b -> ELR a b -> Bool #

(<=) :: ELR a b -> ELR a b -> Bool #

(>) :: ELR a b -> ELR a b -> Bool #

(>=) :: ELR a b -> ELR a b -> Bool #

max :: ELR a b -> ELR a b -> ELR a b #

min :: ELR a b -> ELR a b -> ELR a b #

(Show a, Show b) => Show (ELR a b) # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> ELR a b -> ShowS #

show :: ELR a b -> String #

showList :: [ELR a b] -> ShowS #