decidable 0.1.3.1 → 0.1.4.0
raw patch · 5 files changed
+127/−12 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Type.Predicate.Auto: instance forall a1 (p :: Data.Type.Predicate.Predicate a1) (a2 :: a1). Data.Type.Predicate.Auto.Auto p a2 => Data.Type.Predicate.Auto.AutoAll GHC.Base.Maybe p ('GHC.Base.Just a2)
- Data.Type.Predicate.Auto: instance forall k (a :: k). Data.Singletons.Internal.SingI a => Data.Type.Predicate.Auto.Auto Data.Type.Universe.IsJust ('GHC.Base.Just a)
- Data.Type.Predicate.Auto: instance forall k (a :: k). Data.Type.Predicate.Auto.AutoElem GHC.Base.Maybe ('GHC.Base.Just a) a
- Data.Type.Predicate.Auto: instance forall k (p :: Data.Type.Predicate.Predicate k). Data.Type.Predicate.Auto.AutoAll GHC.Base.Maybe p 'GHC.Base.Nothing
- Data.Type.Predicate.Logic: excludedMiddle :: (p &&& Not p) --> Impossible
- Data.Type.Universe: instance Data.Singletons.Internal.SingKind a => Data.Singletons.Internal.SingKind (Data.Functor.Identity.Identity a)
- Data.Type.Universe: instance Data.Singletons.SuppressUnusedWarnings.SuppressUnusedWarnings Data.Type.Universe.IdentitySym0
- Data.Type.Universe: instance Data.Singletons.SuppressUnusedWarnings.SuppressUnusedWarnings Data.Type.Universe.RunIdentitySym0
- Data.Type.Universe: instance Data.Type.Universe.Universe GHC.Base.Maybe
- Data.Type.Universe: instance forall a (n :: a). Data.Singletons.Internal.SingI n => Data.Singletons.Internal.SingI ('Data.Functor.Identity.Identity n)
- Data.Type.Universe: instance forall k (as :: GHC.Base.Maybe k) (a :: k). GHC.Show.Show (Data.Type.Universe.IJust as a)
- Data.Type.Universe: instance forall k (as :: GHC.Base.Maybe k). (Data.Singletons.Internal.SingI as, Data.Singletons.Decide.SDecide k) => Data.Type.Predicate.Decidable (Data.Type.Predicate.TyPred (Data.Type.Universe.IJust as))
+ Data.Type.Predicate: infixr 1 -?>#
+ Data.Type.Predicate.Auto: instance forall a1 (p :: Data.Type.Predicate.Predicate a1) (a2 :: a1). Data.Type.Predicate.Auto.Auto p a2 => Data.Type.Predicate.Auto.AutoAll GHC.Maybe.Maybe p ('GHC.Maybe.Just a2)
+ Data.Type.Predicate.Auto: instance forall k (a :: k). Data.Singletons.Internal.SingI a => Data.Type.Predicate.Auto.Auto Data.Type.Universe.IsJust ('GHC.Maybe.Just a)
+ Data.Type.Predicate.Auto: instance forall k (a :: k). Data.Type.Predicate.Auto.AutoElem GHC.Maybe.Maybe ('GHC.Maybe.Just a) a
+ Data.Type.Predicate.Auto: instance forall k (p :: Data.Type.Predicate.Predicate k). Data.Type.Predicate.Auto.AutoAll GHC.Maybe.Maybe p 'GHC.Maybe.Nothing
+ Data.Type.Predicate.Logic: complementation :: forall p. (p &&& Not p) --> Impossible
+ Data.Type.Predicate.Logic: infixr 1 <==>
+ Data.Type.Predicate.Logic: infixr 2 |||
+ Data.Type.Predicate.Logic: infixr 3 &&&
+ Data.Type.Predicate.Logic: negateTwice :: p --> Not (Not p)
+ Data.Type.Predicate.Logic: tripleNegation :: forall p. Not (Not (Not p)) --> Not p
+ Data.Type.Predicate.Param: data TyPP :: (k -> v -> Type) -> ParamPred k v
+ Data.Type.Predicate.Param: searchTC :: forall t. SearchableTC t => Decide (Found (TyPP t))
+ Data.Type.Predicate.Param: selectTC :: forall t. SelectableTC t => Prove (Found (TyPP t))
+ Data.Type.Predicate.Param: type SearchableTC t = Decidable (Found (TyPP t))
+ Data.Type.Predicate.Param: type SelectableTC t = Provable (Found (TyPP t))
+ Data.Type.Universe: data family Sing (a :: k) :: Type
+ Data.Type.Universe: instance Data.Type.Universe.Universe GHC.Maybe.Maybe
+ Data.Type.Universe: instance forall k (as :: GHC.Maybe.Maybe k) (a :: k). GHC.Show.Show (Data.Type.Universe.IJust as a)
+ Data.Type.Universe: instance forall k (as :: GHC.Maybe.Maybe k). (Data.Singletons.Internal.SingI as, Data.Singletons.Decide.SDecide k) => Data.Type.Predicate.Decidable (Data.Type.Predicate.TyPred (Data.Type.Universe.IJust as))
+ Data.Type.Universe: type family GetComp c
- Data.Type.Predicate: Wit :: p @@ a -> Wit p a
+ Data.Type.Predicate: Wit :: (p @@ a) -> Wit p a
- Data.Type.Predicate: compImpl :: forall p q r. () => p --> q -> q --> r -> p --> r
+ Data.Type.Predicate: compImpl :: forall p q r. () => (p --> q) -> (q --> r) -> p --> r
- Data.Type.Predicate: dmap :: forall p q. DFunctor f => (p -?> q) -> (f p -?> f q)
+ Data.Type.Predicate: dmap :: forall p q. DFunctor f => (p -?> q) -> f p -?> f q
- Data.Type.Predicate: tmap :: forall p q. TFunctor f => (p --> q) -> (f p --> f q)
+ Data.Type.Predicate: tmap :: forall p q. TFunctor f => (p --> q) -> f p --> f q
- Data.Type.Predicate.Logic: compImpl :: forall p q r. () => p --> q -> q --> r -> p --> r
+ Data.Type.Predicate.Logic: compImpl :: forall p q r. () => (p --> q) -> (q --> r) -> p --> r
- Data.Type.Predicate.Logic: contrapositive :: (p --> q) -> (Not q --> Not p)
+ Data.Type.Predicate.Logic: contrapositive :: (p --> q) -> Not q --> Not p
- Data.Type.Predicate.Logic: contrapositive' :: forall p q. Decidable q => (Not q --> Not p) -> (p --> q)
+ Data.Type.Predicate.Logic: contrapositive' :: forall p q. Decidable q => (Not q --> Not p) -> p --> q
- Data.Type.Predicate.Quantification: WitAll :: forall a. Elem f as a -> p @@ a -> WitAll f p
+ Data.Type.Predicate.Quantification: WitAll :: (forall a. Elem f as a -> p @@ a) -> WitAll f p
- Data.Type.Predicate.Quantification: [WitAny] :: Elem f as a -> p @@ a -> WitAny f p as
+ Data.Type.Predicate.Quantification: [WitAny] :: Elem f as a -> (p @@ a) -> WitAny f p as
- Data.Type.Predicate.Quantification: allComp :: All f (All g p) @@ as -> All (f :.: g) p @@ 'Comp as
+ Data.Type.Predicate.Quantification: allComp :: (All f (All g p) @@ as) -> All (f :.: g) p @@ 'Comp as
- Data.Type.Predicate.Quantification: anyComp :: Any f (Any g p) @@ as -> Any (f :.: g) p @@ 'Comp as
+ Data.Type.Predicate.Quantification: anyComp :: (Any f (Any g p) @@ as) -> Any (f :.: g) p @@ 'Comp as
- Data.Type.Predicate.Quantification: compAll :: All (f :.: g) p @@ 'Comp as -> All f (All g p) @@ as
+ Data.Type.Predicate.Quantification: compAll :: (All (f :.: g) p @@ 'Comp as) -> All f (All g p) @@ as
- Data.Type.Predicate.Quantification: compAny :: Any (f :.: g) p @@ 'Comp as -> Any f (Any g p) @@ as
+ Data.Type.Predicate.Quantification: compAny :: (Any (f :.: g) p @@ 'Comp as) -> Any f (Any g p) @@ as
- Data.Type.Predicate.Quantification: decideEntailAll :: forall f p q. Universe f => p -?> q -> All f p -?> All f q
+ Data.Type.Predicate.Quantification: decideEntailAll :: forall f p q. Universe f => (p -?> q) -> All f p -?> All f q
- Data.Type.Predicate.Quantification: entailAll :: forall f p q. Universe f => (p --> q) -> (All f p --> All f q)
+ Data.Type.Predicate.Quantification: entailAll :: forall f p q. Universe f => (p --> q) -> All f p --> All f q
- Data.Type.Predicate.Quantification: entailAny :: forall f p q. Universe f => (p --> q) -> (Any f p --> Any f q)
+ Data.Type.Predicate.Quantification: entailAny :: forall f p q. Universe f => (p --> q) -> Any f p --> Any f q
- Data.Type.Predicate.Quantification: idecideAll :: forall k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> (Sing as -> Decision (All f p @@ as))
+ Data.Type.Predicate.Quantification: idecideAll :: forall k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> Sing as -> Decision (All f p @@ as)
- Data.Type.Predicate.Quantification: idecideAny :: forall k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> (Sing as -> Decision (Any f p @@ as))
+ Data.Type.Predicate.Quantification: idecideAny :: forall k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> Sing as -> Decision (Any f p @@ as)
- Data.Type.Predicate.Quantification: idecideEntailAll :: forall f p q as. (Universe f, SingI as) => (forall a. Elem f as a -> p @@ a -> Decision (q @@ a)) -> All f p @@ as -> Decision (All f q @@ as)
+ Data.Type.Predicate.Quantification: idecideEntailAll :: forall f p q as. (Universe f, SingI as) => (forall a. Elem f as a -> (p @@ a) -> Decision (q @@ a)) -> (All f p @@ as) -> Decision (All f q @@ as)
- Data.Type.Predicate.Quantification: idecideNone :: forall f k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> (Sing as -> Decision (None f p @@ as))
+ Data.Type.Predicate.Quantification: idecideNone :: forall f k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> Sing as -> Decision (None f p @@ as)
- Data.Type.Predicate.Quantification: ientailAll :: forall f p q as. (Universe f, SingI as) => (forall a. Elem f as a -> Sing a -> p @@ a -> q @@ a) -> All f p @@ as -> All f q @@ as
+ Data.Type.Predicate.Quantification: ientailAll :: forall f p q as. (Universe f, SingI as) => (forall a. Elem f as a -> Sing a -> (p @@ a) -> q @@ a) -> (All f p @@ as) -> All f q @@ as
- Data.Type.Predicate.Quantification: ientailAllF :: forall f p q as h. (Universe f, Applicative h, SingI as) => (forall a. Elem f as a -> p @@ a -> h (q @@ a)) -> All f p @@ as -> h (All f q @@ as)
+ Data.Type.Predicate.Quantification: ientailAllF :: forall f p q as h. (Universe f, Applicative h, SingI as) => (forall a. Elem f as a -> (p @@ a) -> h (q @@ a)) -> (All f p @@ as) -> h (All f q @@ as)
- Data.Type.Predicate.Quantification: ientailAny :: forall f p q as. (Universe f, SingI as) => (forall a. Elem f as a -> Sing a -> p @@ a -> q @@ a) -> Any f p @@ as -> Any f q @@ as
+ Data.Type.Predicate.Quantification: ientailAny :: forall f p q as. (Universe f, SingI as) => (forall a. Elem f as a -> Sing a -> (p @@ a) -> q @@ a) -> (Any f p @@ as) -> Any f q @@ as
- Data.Type.Predicate.Quantification: ientailAnyF :: forall f p q as h. Functor h => (forall a. Elem f as a -> p @@ a -> h (q @@ a)) -> Any f p @@ as -> h (Any f q @@ as)
+ Data.Type.Predicate.Quantification: ientailAnyF :: forall f p q as h. Functor h => (forall a. Elem f as a -> (p @@ a) -> h (q @@ a)) -> (Any f p @@ as) -> h (Any f q @@ as)
- Data.Type.Universe: InL :: (f a) -> (:+:) f g a
+ Data.Type.Universe: InL :: f a -> (:+:) f g a
- Data.Type.Universe: InR :: (g a) -> (:+:) f g a
+ Data.Type.Universe: InR :: g a -> (:+:) f g a
- Data.Type.Universe: WitAll :: forall a. Elem f as a -> p @@ a -> WitAll f p
+ Data.Type.Universe: WitAll :: (forall a. Elem f as a -> p @@ a) -> WitAll f p
- Data.Type.Universe: [WitAny] :: Elem f as a -> p @@ a -> WitAny f p as
+ Data.Type.Universe: [WitAny] :: Elem f as a -> (p @@ a) -> WitAny f p as
- Data.Type.Universe: allComp :: All f (All g p) @@ as -> All (f :.: g) p @@ 'Comp as
+ Data.Type.Universe: allComp :: (All f (All g p) @@ as) -> All (f :.: g) p @@ 'Comp as
- Data.Type.Universe: allSumL :: All f p @@ as -> All (f :+: g) p @@ 'InL as
+ Data.Type.Universe: allSumL :: (All f p @@ as) -> All (f :+: g) p @@ 'InL as
- Data.Type.Universe: allSumR :: All g p @@ bs -> All (f :+: g) p @@ 'InR bs
+ Data.Type.Universe: allSumR :: (All g p @@ bs) -> All (f :+: g) p @@ 'InR bs
- Data.Type.Universe: anyComp :: Any f (Any g p) @@ as -> Any (f :.: g) p @@ 'Comp as
+ Data.Type.Universe: anyComp :: (Any f (Any g p) @@ as) -> Any (f :.: g) p @@ 'Comp as
- Data.Type.Universe: anySumL :: Any f p @@ as -> Any (f :+: g) p @@ 'InL as
+ Data.Type.Universe: anySumL :: (Any f p @@ as) -> Any (f :+: g) p @@ 'InL as
- Data.Type.Universe: anySumR :: Any g p @@ bs -> Any (f :+: g) p @@ 'InR bs
+ Data.Type.Universe: anySumR :: (Any g p @@ bs) -> Any (f :+: g) p @@ 'InR bs
- Data.Type.Universe: compAll :: All (f :.: g) p @@ 'Comp as -> All f (All g p) @@ as
+ Data.Type.Universe: compAll :: (All (f :.: g) p @@ 'Comp as) -> All f (All g p) @@ as
- Data.Type.Universe: compAny :: Any (f :.: g) p @@ 'Comp as -> Any f (Any g p) @@ as
+ Data.Type.Universe: compAny :: (Any (f :.: g) p @@ 'Comp as) -> Any f (Any g p) @@ as
- Data.Type.Universe: data ( f (:+:) g ) a
+ Data.Type.Universe: data ( f :+: g ) a
- Data.Type.Universe: genAllA :: forall f k (p :: k ~> Type) (as :: f k) h. (Universe f, Applicative h) => (forall a. Sing a -> h (p @@ a)) -> (Sing as -> h (All f p @@ as))
+ Data.Type.Universe: genAllA :: forall f k (p :: k ~> Type) (as :: f k) h. (Universe f, Applicative h) => (forall a. Sing a -> h (p @@ a)) -> Sing as -> h (All f p @@ as)
- Data.Type.Universe: idecideAll :: forall k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> (Sing as -> Decision (All f p @@ as))
+ Data.Type.Universe: idecideAll :: forall k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> Sing as -> Decision (All f p @@ as)
- Data.Type.Universe: idecideAny :: forall k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> (Sing as -> Decision (Any f p @@ as))
+ Data.Type.Universe: idecideAny :: forall k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> Decision (p @@ a)) -> Sing as -> Decision (Any f p @@ as)
- Data.Type.Universe: igenAll :: forall f k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> p @@ a) -> (Sing as -> All f p @@ as)
+ Data.Type.Universe: igenAll :: forall f k (p :: k ~> Type) (as :: f k). Universe f => (forall a. Elem f as a -> Sing a -> p @@ a) -> Sing as -> All f p @@ as
- Data.Type.Universe: igenAllA :: forall k (p :: k ~> Type) (as :: f k) h. (Universe f, Applicative h) => (forall a. Elem f as a -> Sing a -> h (p @@ a)) -> (Sing as -> h (All f p @@ as))
+ Data.Type.Universe: igenAllA :: forall k (p :: k ~> Type) (as :: f k) h. (Universe f, Applicative h) => (forall a. Elem f as a -> Sing a -> h (p @@ a)) -> Sing as -> h (All f p @@ as)
- Data.Type.Universe: sumLAll :: All (f :+: g) p @@ 'InL as -> All f p @@ as
+ Data.Type.Universe: sumLAll :: (All (f :+: g) p @@ 'InL as) -> All f p @@ as
- Data.Type.Universe: sumLAny :: Any (f :+: g) p @@ 'InL as -> Any f p @@ as
+ Data.Type.Universe: sumLAny :: (Any (f :+: g) p @@ 'InL as) -> Any f p @@ as
- Data.Type.Universe: sumRAll :: All (f :+: g) p @@ 'InR bs -> All g p @@ bs
+ Data.Type.Universe: sumRAll :: (All (f :+: g) p @@ 'InR bs) -> All g p @@ bs
- Data.Type.Universe: sumRAny :: Any (f :+: g) p @@ 'InR bs -> Any g p @@ bs
+ Data.Type.Universe: sumRAny :: (Any (f :+: g) p @@ 'InR bs) -> Any g p @@ bs
- Data.Type.Universe.Subset: WitSubset :: forall a. Elem f as a -> Decision (p @@ a) -> WitSubset f p
+ Data.Type.Universe.Subset: WitSubset :: (forall a. Elem f as a -> Decision (p @@ a)) -> WitSubset f p
- Data.Type.Universe.Subset: imapSubset :: (forall a. Elem f as a -> p @@ a -> q @@ a) -> (forall a. Elem f as a -> q @@ a -> p @@ a) -> Subset f p @@ as -> Subset f q @@ as
+ Data.Type.Universe.Subset: imapSubset :: (forall a. Elem f as a -> (p @@ a) -> q @@ a) -> (forall a. Elem f as a -> (q @@ a) -> p @@ a) -> (Subset f p @@ as) -> Subset f q @@ as
- Data.Type.Universe.Subset: imergeSubset :: forall f k p q r (as :: f k). () => (forall a. Elem f as a -> Decision (p @@ a) -> Decision (q @@ a) -> Decision (r @@ a)) -> Subset f p @@ as -> Subset f q @@ as -> Subset f r @@ as
+ Data.Type.Universe.Subset: imergeSubset :: forall f k p q r (as :: f k). () => (forall a. Elem f as a -> Decision (p @@ a) -> Decision (q @@ a) -> Decision (r @@ a)) -> (Subset f p @@ as) -> (Subset f q @@ as) -> Subset f r @@ as
- Data.Type.Universe.Subset: intersection :: forall f p q. () => ((Subset f p &&& Subset f q) --> Subset f (p &&& q))
+ Data.Type.Universe.Subset: intersection :: forall f p q. () => (Subset f p &&& Subset f q) --> Subset f (p &&& q)
- Data.Type.Universe.Subset: mapSubset :: Universe f => (p --> q) -> (q --> p) -> (Subset f p --> Subset f q)
+ Data.Type.Universe.Subset: mapSubset :: Universe f => (p --> q) -> (q --> p) -> Subset f p --> Subset f q
- Data.Type.Universe.Subset: mergeSubset :: forall f k p q r (as :: f k). () => (forall a. Decision (p @@ a) -> Decision (q @@ a) -> Decision (r @@ a)) -> Subset f p @@ as -> Subset f q @@ as -> Subset f r @@ as
+ Data.Type.Universe.Subset: mergeSubset :: forall f k p q r (as :: f k). () => (forall a. Decision (p @@ a) -> Decision (q @@ a) -> Decision (r @@ a)) -> (Subset f p @@ as) -> (Subset f q @@ as) -> Subset f r @@ as
- Data.Type.Universe.Subset: symDiff :: forall f p q. () => ((Subset f p &&& Subset f q) --> Subset f (p ^^^ q))
+ Data.Type.Universe.Subset: symDiff :: forall f p q. () => (Subset f p &&& Subset f q) --> Subset f (p ^^^ q)
- Data.Type.Universe.Subset: union :: forall f p q. () => ((Subset f p &&& Subset f q) --> Subset f (p ||| q))
+ Data.Type.Universe.Subset: union :: forall f p q. () => (Subset f p &&& Subset f q) --> Subset f (p ||| q)
Files
- CHANGELOG.md +14/−0
- decidable.cabal +2/−2
- src/Data/Type/Predicate.hs +7/−4
- src/Data/Type/Predicate/Logic.hs +26/−5
- src/Data/Type/Predicate/Param.hs +78/−1
CHANGELOG.md view
@@ -1,6 +1,20 @@ Changelog ========= +Version 0.1.4.0+---------------++*October 29, 2018*++<https://github.com/mstksg/decidable/releases/tag/v0.1.4.0>++* Added `tripleNegative` and `negateTwice` to *Data.Type.Predicate.Logic*,+ for more constructivist principles.+* Renamed `excludedMiddle` to `complementation`.+* Add `TyPP`, `SearchableTC`, `searchTC`, `SelectableTC`, `selectTC` to+ *Data.Type.Predicate.Param*, to mirror `TyPred` and the+ `DecidableTC`/`ProvableTC` interface from *Data.Type.Predicate*+ Version 0.1.3.1 ---------------
decidable.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 8f4356d2d59f7c72a3fb5358dda90a0b36b47bb7fd03398fb1ed2c4c631a5a77+-- hash: 6e9513846ace27e5bfa2f348d6298c6ad1245b42db00135bb2aa42c5203f095e name: decidable-version: 0.1.3.1+version: 0.1.4.0 synopsis: Combinators for manipulating dependently-typed predicates. description: This library provides combinators and typeclasses for working and manipulating type-level predicates in Haskell, which are represented as matchable type-level
src/Data/Type/Predicate.hs view
@@ -277,9 +277,10 @@ -- -- Is essentially 'Decidable', except with /type constructors/ @k -> -- 'Type'@ instead of matchable type-level functions (that are @k ~>--- 'Type'@).+-- 'Type'@). Useful because 'decideTC' doesn't require anything fancy like+-- TypeApplications to use. ----- Mostly is in this library for compatiblity with "traditional" predicates+-- Also is in this library for compatiblity with "traditional" predicates -- that are GADT type constructors. -- -- @since 0.1.1.0@@ -305,8 +306,10 @@ -- -- Is essentially 'Provable', except with /type constructors/ @k -> 'Type'@ -- instead of matchable type-level functions (that are @k ~> 'Type'@).+-- Useful because 'proveTC' doesn't require anything fancy like+-- TypeApplications to use. ----- Mostly is in this library for compatiblity with "traditional" predicates+-- Also is in this library for compatiblity with "traditional" predicates -- that are GADT type constructors. -- -- @since 0.1.1.0@@ -373,7 +376,7 @@ -- | Flip the contents of a decision. Turn a proof of @a@ into a disproof -- of not-@a@. ----- Note that this is not reversible in general in Haskell. See+-- Note that this is not reversible in general in constructivist logic See -- 'Data.Type.Predicate.Logic.doubleNegation' for a situation where it is. -- -- @since 0.1.1.0
src/Data/Type/Predicate/Logic.hs view
@@ -33,7 +33,8 @@ , type (==>), proveImplies, Implies , type (<==>), Equiv -- * Logical deductions- , compImpl, explosion, atom, excludedMiddle, doubleNegation+ , compImpl, explosion, atom+ , complementation, doubleNegation, tripleNegation, negateTwice , contrapositive, contrapositive' -- ** Lattice , projAndFst, projAndSnd, injOrLeft, injOrRight@@ -206,18 +207,22 @@ atom = const -- | We cannot have both @p@ and @'Not' p@.-excludedMiddle :: (p &&& Not p) --> Impossible-excludedMiddle _ (p, notP) _ = notP p+--+-- (Renamed in v0.1.4.0; used to be 'excludedMiddle')+--+-- @since 0.1.4.0+complementation :: forall p. (p &&& Not p) --> Impossible+complementation _ (p, notP) _ = notP p -- | @since 0.1.3.0 instance {-# OVERLAPPING #-} Provable (p &&& Not p ==> Impossible) where- prove = excludedMiddle @p+ prove = complementation @p -- | If p implies q, then not q implies not p. contrapositive :: (p --> q) -> (Not q --> Not p)-contrapositive f x v p = v (f x p)+contrapositive f x vQ p = vQ (f x p) -- | Reverse direction of 'contrapositive'. Only possible if @q@ is -- 'Decidable' on its own, without the help of @p@, which makes this much@@ -230,9 +235,25 @@ f x vQ p -- | Logical double negation. Only possible if @p@ is 'Decidable'.+--+-- This is because in constructivist logic, not (not p) does not imply p.+-- However, p implies not (not p) (see 'negateTwice'), and not (not (not+-- p)) implies not p (see 'tripleNegation') doubleNegation :: forall p. Decidable p => Not (Not p) --> p doubleNegation x vvP = elimDisproof (decide @p x) $ \vP -> vvP vP++-- | In constructivist logic, not (not (not p)) implies not p.+--+-- @since 0.1.4.0+tripleNegation :: forall p. Not (Not (Not p)) --> Not p+tripleNegation _ vvvP p = vvvP $ \vP -> vP p++-- | In constructivist logic, p implies not (not p).+--+-- @since 0.1.4.0+negateTwice :: p --> Not (Not p)+negateTwice _ p vP = vP p -- | If @p '&&&' q@ is true, then so is @p@. projAndFst :: (p &&& q) --> p
src/Data/Type/Predicate/Param.hs view
@@ -25,16 +25,20 @@ module Data.Type.Predicate.Param ( -- * Parameterized Predicates ParamPred- , FlipPP, ConstPP, PPMap, InP, AnyMatch+ , FlipPP, ConstPP, PPMap, InP, AnyMatch, TyPP -- * Deciding and Proving , Found, NotFound , Selectable, select , Searchable, search , inPNotNull, notNullInP+ -- ** Type Constructors+ , SelectableTC, selectTC+ , SearchableTC, searchTC -- * Combining , OrP, AndP ) where +import Data.Kind import Data.Singletons import Data.Singletons.Prelude.Tuple import Data.Singletons.Sigma@@ -97,6 +101,17 @@ data ConstPP :: Predicate v -> ParamPred k v type instance Apply (ConstPP p k) v = p @@ v +-- | Convert a normal '->' type constructor taking two arguments into+-- a 'ParamPred'.+--+-- @+-- 'TyPP' :: (k -> v -> 'Type') -> 'ParamPred' k v+-- @+--+-- @since 0.1.4.0+data TyPP :: (k -> v -> Type) -> ParamPred k v+type instance Apply (TyPP t k) v = t k v+ -- | Pre-compose a function to a 'ParamPred'. Is essentially @'flip' -- ('.')@, but unfortunately defunctionalization doesn't work too well with -- that definition.@@ -147,6 +162,68 @@ :: forall p. Selectable p => Prove (Found p) select = prove @(Found p)++-- | If @T :: k -> v -> 'Type'@ is a type constructor, then @'SearchableTC'+-- T@ is a constraint that @T@ is "searchable", in that you have+-- a canonical function:+--+-- @+-- 'searchTC' :: 'Sing' x -> 'Decision' (Σ v ('TyPP' T x))+-- @+--+-- That, given an @x :: k@, we can decide whether or not a @y :: v@ exists+-- that satisfies @T x y@.+--+-- Is essentially 'Searchable', except with /type constructors/ @k ->+-- 'Type'@ instead of matchable type-level functions (that are @k ~>+-- 'Type'@). Useful because 'searchTC' doesn't require anything fancy like+-- TypeApplications to use.+--+-- @since 0.1.4.0+type SearchableTC t = Decidable (Found (TyPP t))++-- | If @T :: k -> v -> 'Type'@ is a type constructor, then @'Selectable'+-- T@ is a constraint that @T@ is "selectable", in that you have+-- a canonical function:+--+-- @+-- 'selectTC' :: 'Sing' a -> Σ v ('TyPP' T x)+-- @+--+-- That is, given an @x :: k@, we can /always/ find a @y :: k@ that+-- satisfies @T x y@.+--+-- Is essentially 'Selectable', except with /type constructors/ @k ->+-- 'Type'@ instead of matchable type-level functions (that are @k ~>+-- 'Type'@). Useful because 'selectTC' doesn't require anything fancy like+-- TypeApplications to use.+--+-- @since 0.1.4.0+type SelectableTC t = Provable (Found (TyPP t))++-- | The canonical selecting function for @'Searchable' t@.+--+-- Note that because @t@ must be an injective type constructor, you can use+-- this without explicit type applications; the instance of 'SearchableTC'+-- can be inferred from the result type.+--+-- @since 0.1.4.0+searchTC+ :: forall t. SearchableTC t+ => Decide (Found (TyPP t))+searchTC = search @(TyPP t)++-- | The canonical selecting function for @'SelectableTC' t@.+--+-- Note that because @t@ must be an injective type constructor, you can use+-- this without explicit type applications; the instance of 'SelectableTC'+-- can be inferred from the result type.+--+-- @since 0.1.4.0+selectTC+ :: forall t. SelectableTC t+ => Prove (Found (TyPP t))+selectTC = select @(TyPP t) -- | A @'ParamPred' (f k) k@. Parameterized on an @as :: f k@, returns -- a predicate that is true if there exists any @a :: k@ in @as@.