-
Notifications
You must be signed in to change notification settings - Fork 257
Closed
Description
Hello there. I was doing some stuff with decidable equality and ended up needed the following operations:
imap : ∀ {ℓ} {a b : Set ℓ} → (a → b) → (b → a) → Dec a → Dec b
imap f _ (yes x) = yes (f x)
imap _ g (no x) = no $ x ∘ g
zip : ∀ {ℓ} {a b : Set ℓ} → Dec a → Dec b → Dec (a × b)
zip (yes x) (yes y) = yes $ (x , y)
zip (no x) _ = no $ λ { (x' , _) → x x' }
zip _ (no y) = no $ λ { (_ , y') → y y' }
_∪_ : ∀ {ℓ} {a b : Set ℓ} → Dec a → Dec b → Dec (a ⊎ b)
_∪_ (yes a) _ = yes (inj₁ a)
_∪_ (no a) b = imap inj₂ ([ ⊥-elim ∘ a , id ]′) b
Does it make any sense to add these to the Relation.Nullary
module that Dec
is exported from?