Skip to content

Commit 61e7707

Browse files
add search function to Data.List.Relation.Unary.All (#2428)
* adds `search` function * Nathan's suggestions * added `CHANGELOG` entry --------- Co-authored-by: MatthewDaggitt <[email protected]>
1 parent a6da449 commit 61e7707

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ New modules
3232
Additions to existing modules
3333
-----------------------------
3434

35+
* In `Data.List.Relation.Unary.All`:
36+
```agda
37+
search : Decidable P → ∀ xs → All (∁ P) xs ⊎ Any P xs
38+
```
39+
3540
* In `Data.List.Relation.Binary.Equality.Setoid`:
3641
```agda
3742
++⁺ʳ : ∀ xs → ys ≋ zs → xs ++ ys ≋ xs ++ zs

src/Data/List/Relation/Unary/All.agda

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ open import Data.List.Membership.Propositional renaming (_∈_ to _∈ₚ_)
1414
import Data.List.Membership.Setoid as SetoidMembership
1515
open import Data.Product.Base as Product
1616
using (∃; -,_; _×_; _,_; proj₁; proj₂; uncurry)
17-
open import Data.Sum.Base as Sum using (inj₁; inj₂)
17+
open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂)
1818
open import Effect.Applicative
1919
open import Effect.Monad
2020
open import Function.Base using (_∘_; _∘′_; id; const)
@@ -232,6 +232,9 @@ decide p∪q (x ∷ xs) with p∪q x
232232
... | inj₂ qx = inj₂ (here qx)
233233
... | inj₁ px = Sum.map (px ∷_) there (decide p∪q xs)
234234

235+
search : Decidable P xs All (∁ P) xs ⊎ Any P xs
236+
search P? = decide (Sum.swap ∘ Dec.toSum ∘ P?)
237+
235238
------------------------------------------------------------------------
236239
-- DEPRECATED
237240
------------------------------------------------------------------------

0 commit comments

Comments
 (0)