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

Predicate.Data.Lifted

Description

lifted promoted functions

Synopsis

functor

data FMap p Source #

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

Instances details
(Traversable n, P p a) => P (FMap p :: Type) (n a) Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (FMap p) (n a) Source #

Methods

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

Show (FMap p) Source # 
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) Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data p <$> q infixl 4 Source #

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

Instances details
(Traversable n, P q a, P p b, PP q a ~ n b, PP p b ~ c) => P (p <$> q :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <$> q) a Source #

Methods

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

Show (p <$> q) Source # 
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 Source # 
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 Source #

similar to <&>

>>> pz @('[1,2,3] <&> Succ) ()
Val [2,3,4]

Instances

Instances details
P (FMapFlipT p q) x => P (p <&> q :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <&> q) x Source #

Methods

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

Show (p <&> q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

applicative

data Pure (t :: Type -> Type) p Source #

similar to pure

>>> pz @(Pure Maybe Id) 4
Val (Just 4)
>>> pz @(Pure [] Id) 4
Val [4]
>>> pz @(Pure (Either String) Fst) (13,True)
Val (Right 13)
>>> pl @(Pure Maybe Id) 'x'
Present Just 'x' (Pure Just 'x' | 'x')
Val (Just 'x')
>>> pl @(Pure (Either _) Id) 'x'
Present Right 'x' (Pure Right 'x' | 'x')
Val (Right 'x')
>>> pl @(Pure (Either _) Id >> Swap) 'x'
Present Left 'x' ((>>) Left 'x' | {Swap Left 'x' | Right 'x'})
Val (Left 'x')
>>> pl @(Pure (Either ()) Id >> Swap) 'x'
Present Left 'x' ((>>) Left 'x' | {Swap Left 'x' | Right 'x'})
Val (Left 'x')
>>> pl @(Pure (Either String) Id >> Swap) 123
Present Left 123 ((>>) Left 123 | {Swap Left 123 | Right 123})
Val (Left 123)

Instances

Instances details
(P p x, Show (PP p x), Show (t (PP p x)), Applicative t) => P (Pure t p :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Pure t p) x Source #

Methods

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

Show (Pure t p) Source # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Pure t p -> ShowS #

show :: Pure t p -> String #

showList :: [Pure t p] -> ShowS #

type PP (Pure t p :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Pure t p :: Type) x = t (PP p x)

data p <*> q infixl 1 Source #

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

Instances details
P (AppT p q) x => P (p <*> q :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <*> q) x Source #

Methods

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

Show (p <*> q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data LiftA2 p q r Source #

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

Instances details
(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 Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (LiftA2 p q r) x Source #

Methods

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

Show (LiftA2 p q r) Source # 
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 Source # 
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 Source #

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)]
>>> pz @(FPair '[ '() ] (1 ... 5)) True
Val [((),1),((),2),((),3),((),4),((),5)]

Instances

Instances details
(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 Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (FPair p q) a Source #

Methods

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

Show (FPair p q) Source # 
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 Source # 
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 Source #

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

Instances details
P (FPairT p q) x => P (p <:> q :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

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

Methods

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

Show (p <:> q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data p <$ q infixl 4 Source #

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

Instances details
(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 Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <$ q) x Source #

Methods

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

Show (p <$ q) Source # 
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 Source # 
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 Source #

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

Instances details
(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 Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <* q) x Source #

Methods

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

Show (p <* q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data p *> q infixl 4 Source #

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

Instances details
(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 Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p *> q) x Source #

Methods

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

Show (p *> q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

monad

data FFish amb bmc a Source #

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

Instances details
P (FFishT p q r) x => P (FFish p q r :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (FFish p q r) x Source #

Methods

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

Show (FFish amb bmc a) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data ma >>= amb infixl 1 Source #

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

Instances details
P (MBindT p q) x => P (p >>= q :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p >>= q) x Source #

Methods

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

Show (ma >>= amb) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data Sequence Source #

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

Instances details
Show Sequence Source # 
Instance details

Defined in Predicate.Data.Lifted

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

Defined in Predicate.Data.Lifted

Associated Types

type PP Sequence (t (f a)) Source #

Methods

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

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

Defined in Predicate.Data.Lifted

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

data Traverse p Source #

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

Instances details
P (TraverseT p) x => P (Traverse p :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Traverse p) x Source #

Methods

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

Show (Traverse p) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Traverse p :: Type) x

data Join Source #

similar to join

>>> pz @Join (Just (Just 20))
Val (Just 20)
>>> pz @Join ["ab","cd","","ef"]
Val "abcdef"

Instances

Instances details
Show Join Source # 
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)) Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP Join (t (t a)) Source #

Methods

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

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

Defined in Predicate.Data.Lifted

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

alternative

data p <|> q infixl 3 Source #

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

Instances details
(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 Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p <|> q) x Source #

Methods

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

Show (p <|> q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data EmptyT (t :: Type -> Type) (t1 :: Type) Source #

similar to empty

>>> pz @(EmptyT Maybe _) ()
Val Nothing
>>> pz @(EmptyT [] _) ()
Val []
>>> pz @(C "x" >> EmptyT [] String) (13,True)
Val []
>>> pz @(Fst >> EmptyT (Either String) _) (13,True)
Val (Left "")
>>> pz @(If 'True (MkJust 11) (EmptyT _ _)) ()
Val (Just 11)
>>> pz @(EmptyT [] _ <> "123") ()
Val "123"

Instances

Instances details
Alternative t => P (EmptyT t t1 :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (EmptyT t t1) x Source #

Methods

eval :: MonadEval m => proxy (EmptyT t t1) -> POpts -> x -> m (TT (PP (EmptyT t t1) x)) Source #

Show (EmptyT t t1) Source # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> EmptyT t t1 -> ShowS #

show :: EmptyT t t1 -> String #

showList :: [EmptyT t t1] -> ShowS #

type PP (EmptyT t t1 :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (EmptyT t t1 :: Type) x

data EmptyT' (t :: Type -> Type) p Source #

similar to empty where t is the type of the container and t1 is a reference to the type of the items in the container

>>> pz @(EmptyT' [] "x") ()
Val []
>>> pz @(EmptyT' (Either String) (1 % 1)) ()
Val (Left "")
>>> pl @(If 'True (MkJust 11) (EmptyT' _ 0)) ()
Present Just 11 (If 'True Just 11)
Val (Just 11)
>>> pz @(If 'True (MkJust 11) (EmptyT' _ (Hole Int))) ()
Val (Just 11)
>>> pz @(If 'False (MkJust 11) (EmptyT' _ (Hole Int))) ()
Val Nothing

Instances

Instances details
Alternative t => P (EmptyT' t p :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (EmptyT' t p) x Source #

Methods

eval :: MonadEval m => proxy (EmptyT' t p) -> POpts -> x -> m (TT (PP (EmptyT' t p) x)) Source #

Show (EmptyT' t p) Source # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> EmptyT' t p -> ShowS #

show :: EmptyT' t p -> String #

showList :: [EmptyT' t p] -> ShowS #

type PP (EmptyT' t p :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (EmptyT' t p :: Type) x = t (PP p x)

data EmptyList (t :: Type) Source #

creates an empty list for the given type

>>> pz @(Id :+ EmptyList _) 99
Val [99]

Instances

Instances details
Show (EmptyList t) Source # 
Instance details

Defined in Predicate.Data.Lifted

P (EmptyList t :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (EmptyList t) x Source #

Methods

eval :: MonadEval m => proxy (EmptyList t) -> POpts -> x -> m (TT (PP (EmptyList t) x)) Source #

type PP (EmptyList t :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (EmptyList t :: Type) x

data EmptyList' (t :: k) Source #

creates an empty list for the given pointer to a type t

>>> pz @(EmptyList' 123 +: Id) 99
Val [99]

Instances

Instances details
P (EmptyList' t :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (EmptyList' t) x Source #

Methods

eval :: MonadEval m => proxy (EmptyList' t) -> POpts -> x -> m (TT (PP (EmptyList' t) x)) Source #

Show (EmptyList' t) Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (EmptyList' t :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (EmptyList' t :: Type) x

data EmptyBool t b p Source #

Convenient method to convert a value p to an Alternative based on a predicate b

if b is True then pure p else empty

>>> pz @(EmptyBool [] (Id > 4) 'True) 24
Val [True]
>>> pz @(EmptyBool [] (Id > 4) 'True) 1
Val []

Instances

Instances details
(Show (PP p a), P b a, P p a, PP b a ~ Bool, Alternative t) => P (EmptyBool t b p :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (EmptyBool t b p) a Source #

Methods

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

Show (EmptyBool t b p) Source # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> EmptyBool t b p -> ShowS #

show :: EmptyBool t b p -> String #

showList :: [EmptyBool t b p] -> ShowS #

type PP (EmptyBool t b p :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (EmptyBool t b p :: Type) a = t (PP p a)

data EmptyBool' b p Source #

Convenient method to convert a value p to an Alternative based on a predicate b the value of p drives the choice of Alternative to use for the empty similar to EmptyBool but no need to provide t as it is inferred from the resulting type of p

if b is True then run p else empty

>>> pz @(EmptyBool' (Id > 4) (MkJust (Id * 3))) 24
Val (Just 72)
>>> pz @(EmptyBool' (Id > 4) (MkJust (Id * 3))) 2
Val Nothing
>>> pz @(EmptyBool' (Len > 0) Head) ["Abcd","def","g"::String]
Val "Abcd"
>>> pz @(EmptyBool' (Len > 0) Head) ([] :: [String])
Val ""

Instances

Instances details
(Show (PP p a), P b a, P p a, PP p a ~ t x, PP b a ~ Bool, Alternative t) => P (EmptyBool' b p :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (EmptyBool' b p) a Source #

Methods

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

Show (EmptyBool' b p) Source # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> EmptyBool' b p -> ShowS #

show :: EmptyBool' b p -> String #

showList :: [EmptyBool' b p] -> ShowS #

type PP (EmptyBool' b p :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (EmptyBool' b p :: Type) a = PP p a

bifunctor

data BiMap p q Source #

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) (ENone @Int @String)
Present ENone (BiMap <skipped>)
Val ENone
>>> 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) [ENone,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 [ENone,ELeft 11,ERight 'a',EBoth 11 'x']

Instances

Instances details
(Bitraversable n, P p a, P q b) => P (BiMap p q :: Type) (n a b) Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (BiMap p q) (n a b) Source #

Methods

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

Show (BiMap p q) Source # 
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) Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data BiFoldMap p q Source #

a version of bifoldMap

>>> pl @(BiFoldMap Id Id) (Right [10..13])
Present [10,11,12,13] (BiFoldMap(R) Id [10,11,12,13])
Val [10,11,12,13]
>>> pl @(BiFoldMap Id Id) (Left [10..13])
Present [10,11,12,13] (BiFoldMap(L) Id [10,11,12,13])
Val [10,11,12,13]
>>> pl @(BiFoldMap Id Id) (SG.Arg [1..5] [10..13])
Present [1,2,3,4,5,10,11,12,13] (BiFoldMap(B) Id [1,2,3,4,5] | Id [10,11,12,13])
Val [1,2,3,4,5,10,11,12,13]
>>> pz @(BiFoldMap (Wrap (SG.Sum _) Id) (Wrap (SG.Sum _) Id)) (SG.Arg 1 4)
Val (Sum {getSum = 5})
>>> pl @(BiFoldMap '( '[Id], '[]) '( '[], '[Id])) (SG.Arg "hap" "bcd")
Present (["hap"],["bcd"]) (BiFoldMap(B) '(["hap"],[]) | '([],["bcd"]))
Val (["hap"],["bcd"])
>>> pz @(BiFoldMap '(Wrap (SG.Sum _) Id, MEmptyT _) '(MEmptyT _, Id)) (SG.Arg 123 "xyz")
Val (Sum {getSum = 123},"xyz")
>>> pl @(BiFoldMap '(Wrap (SG.Sum _) Id, MEmptyT _) '(MEmptyT _, Id)) (Left 123)
Present (Sum {getSum = 123},()) (BiFoldMap(L) '(Sum {getSum = 123},()))
Val (Sum {getSum = 123},())
>>> pz @(BiFoldMap (MEmptyT _) $ FoldMap (FoldMap (Wrap (SG.Sum _) Id))) (Right (Just [1..10]))
Val (Sum {getSum = 55})

Instances

Instances details
(Bitraversable n, Monoid t, PP p a ~ t, PP q b ~ t, P p a, P q b) => P (BiFoldMap p q :: Type) (n a b) Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (BiFoldMap p q) (n a b) Source #

Methods

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

Show (BiFoldMap p q) Source # 
Instance details

Defined in Predicate.Data.Lifted

Methods

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

show :: BiFoldMap p q -> String #

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

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

Defined in Predicate.Data.Lifted

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

comonad

data Extract Source #

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

Instances details
Show Extract Source # 
Instance details

Defined in Predicate.Data.Lifted

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

Defined in Predicate.Data.Lifted

Associated Types

type PP Extract (t a) Source #

Methods

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

type PP Extract (t a) Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP Extract (t a) = a

data Duplicate Source #

similar to duplicate

>>> pz @Duplicate (20,"abc")
Val (20,(20,"abc"))

Instances

Instances details
Show Duplicate Source # 
Instance details

Defined in Predicate.Data.Lifted

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

Defined in Predicate.Data.Lifted

Associated Types

type PP Duplicate (t a) Source #

Methods

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

type PP Duplicate (t a) Source # 
Instance details

Defined in Predicate.Data.Lifted

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

function application

data p $$ q infixl 0 Source #

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 $$ "abc" $$ Wrap (SG.Sum _) 14) >> Id <> Id) These
Val (These "abcabc" (Sum {getSum = 28}))

Instances

Instances details
(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 Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (p $$ q) x Source #

Methods

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

Show (p $$ q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data q $& p infixr 1 Source #

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

Instances details
(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 Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (q $& p) x Source #

Methods

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

Show (q $& p) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data Skip p Source #

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

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

Defined in Predicate.Data.Lifted

Associated Types

type PP (Skip p) a Source #

Methods

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

Show (Skip p) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data p |> q infixr 1 Source #

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

Instances

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

Defined in Predicate.Data.Lifted

Associated Types

type PP (p |> q) x Source #

Methods

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

Show (p |> q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data p >| q infixr 1 Source #

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

Instances

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

Defined in Predicate.Data.Lifted

Associated Types

type PP (p >| q) x Source #

Methods

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

Show (p >| q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data p >|> q infixr 1 Source #

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

Instances

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

Defined in Predicate.Data.Lifted

Associated Types

type PP (p >|> q) x Source #

Methods

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

Show (p >|> q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

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

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

Instances details
P (p r q) x => P (Flip p q r :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Flip p q r) x Source #

Methods

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

Show (Flip p q r) Source # 
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 Source # 
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) Source #

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

Instances details
P (DotExpandT ps q) a => P (Dot ps q :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Dot ps q) a Source #

Methods

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

Show (Dot ps q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Dot ps q :: Type) a = PP (DotExpandT ps q) a

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

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

Instances details
P (RDotExpandT ps q) a => P (RDot ps q :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (RDot ps q) a Source #

Methods

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

Show (RDot ps q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (RDot ps q :: Type) a = PP (RDotExpandT ps q) a

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

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

Instances details
P p a => P (K p q :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (K p q) a Source #

Methods

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

Show (K p q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data Lift p q Source #

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

Instances details
P (LiftT p q) x => P (Lift p q :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Lift p q) x Source #

Methods

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

Show (Lift p q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Lift p q :: Type) x

coerce

data Coerce (t :: Type) Source #

similar to coerce

>>> pz @(Coerce (SG.Sum Integer)) (Identity (-13))
Val (Sum {getSum = -13})
>>> pl @(Coerce SG.Any) True
Present Any {getAny = True} (Coerce Any {getAny = True} | True)
Val (Any {getAny = True})
>>> pl @(Coerce Bool) (SG.Any True)
Present True (Coerce True | Any {getAny = True})
Val True
>>> pz @(Proxy 'True >> Coerce (Proxy 'False)) () ^!? acts . _Val . to typeRep
Just 'False
>>> pz @(Proxy Int >> Coerce (Proxy (String,Char))) () ^!? acts . _Val . to typeRep
Just ([Char],Char)
>>> import qualified GHC.Exts as GE
>>> pz @(Proxy GE.Any >> Coerce (Proxy Int)) () ^!? acts . _Val . to typeRep
Just Int
>>> pz @(Proxy '(_,_) >> Coerce (Proxy '(Float,Int))) () ^!? acts . _Val . to typeRep
Just ('(,) * * Float Int)

Instances

Instances details
Show (Coerce t) Source # 
Instance details

Defined in Predicate.Data.Lifted

Methods

showsPrec :: Int -> Coerce t -> ShowS #

show :: Coerce t -> String #

showList :: [Coerce t] -> ShowS #

(Coercible t a, Show a, Show t) => P (Coerce t :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Coerce t) a Source #

Methods

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

type PP (Coerce t :: Type) a Source # 
Instance details

Defined in Predicate.Data.Lifted

type PP (Coerce t :: Type) a = t

error handling

data Catch p q Source #

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

Instances details
(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 Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Catch p q) x Source #

Methods

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

Show (Catch p q) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

data Catch' p s Source #

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

Instances details
P (CatchT' p s) x => P (Catch' p s :: Type) x Source # 
Instance details

Defined in Predicate.Data.Lifted

Associated Types

type PP (Catch' p s) x Source #

Methods

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

Show (Catch' p s) Source # 
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 Source # 
Instance details

Defined in Predicate.Data.Lifted

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

type families

type family DotExpandT (ps :: [Type -> Type]) (q :: Type) :: Type where ... Source #

calculates the return type for Dot

Equations

DotExpandT '[] _ = TypeError ('Text "'[] invalid: requires at least one predicate in the list") 
DotExpandT '[p] q = p $ q 
DotExpandT (p ': (p1 ': ps)) q = p $ DotExpandT (p1 ': ps) q 

type family RDotExpandT (ps :: [Type -> Type]) (q :: Type) :: Type where ... Source #

calculates the return type for RDot

Equations

RDotExpandT '[] _ = TypeError ('Text "'[] invalid: requires at least one predicate in the list") 
RDotExpandT '[p] q = p $ q 
RDotExpandT (p ': (p1 ': ps)) q = RDotExpandT (p1 ': ps) (p $ q)