summaryrefslogtreecommitdiff
path: root/src/Inky/OnlyWhen.idr
diff options
context:
space:
mode:
authorGreg Brown <greg.brown01@ed.ac.uk>2024-09-09 11:33:45 +0100
committerGreg Brown <greg.brown01@ed.ac.uk>2024-09-09 11:33:45 +0100
commit3a23bd851fc1a5d6e161dabc8a13f06bc8544a1d (patch)
tree301955e4e32dc7d5edafb98e7e373d439168e420 /src/Inky/OnlyWhen.idr
parent3da61a4ffb9cb2d535d518e70c6c90cd73cc3573 (diff)
Restart.
- use De Bruijn, as Namely, Painless had more pain than promised; - remove higher-kinded types; - provide ill-typing predicates; - prove substitution respects ill-typing;
Diffstat (limited to 'src/Inky/OnlyWhen.idr')
-rw-r--r--src/Inky/OnlyWhen.idr44
1 files changed, 0 insertions, 44 deletions
diff --git a/src/Inky/OnlyWhen.idr b/src/Inky/OnlyWhen.idr
deleted file mode 100644
index 7bed91a..0000000
--- a/src/Inky/OnlyWhen.idr
+++ /dev/null
@@ -1,44 +0,0 @@
-module Inky.OnlyWhen
-
-import Data.DPair
-
-public export
-data OnlyWhen : Maybe a -> (a -> Type) -> Type where
- Yes : forall x. (px : p x) -> Just x `OnlyWhen` p
- No : ((x : a) -> Not (p x)) -> Nothing `OnlyWhen` p
-
-public export
-decDPair : (v ** v `OnlyWhen` p) <=> Dec (x : a ** p x)
-decDPair =
- MkEquivalence
- { leftToRight = \case
- (Just x ** Yes px) => Yes (x ** px)
- (Nothing ** No prf) => No (\(x ** px) => prf x px)
- , rightToLeft = \case
- Yes (x ** px) => (Just x ** Yes px)
- No prf => (Nothing ** No (\x, px => prf (x ** px)))
- }
-
-public export
-decExists : Exists (`OnlyWhen` p) <=> Dec (Exists p)
-decExists =
- MkEquivalence
- { leftToRight = \case
- Evidence .(Just x) (Yes px) => Yes (Evidence x px)
- Evidence .(Nothing) (No prf) => No (\(Evidence x px) => void (prf x px))
- , rightToLeft = \case
- Yes (Evidence x px) => Evidence (Just x) (Yes px)
- No prf => Evidence Nothing (No (\x, px => prf (Evidence x px)))
- }
-
-public export
-decSubset : Subset (Maybe a) (`OnlyWhen` p) <=> Dec (Subset a p)
-decSubset =
- MkEquivalence
- { leftToRight = \case
- Element (Just x) prf => Yes (Element x (case prf of Yes px => px))
- Element Nothing prf => No (\(Element x px) => void (case prf of No prf => prf x px))
- , rightToLeft = \case
- Yes (Element x px) => Element (Just x) (Yes px)
- No prf => Element Nothing (No (\x, px => prf (Element x px)))
- }