Skip to content

Commit 31d59e4

Browse files
authored
[ refactor ] Add Data.Bool.ListAction (#2561)
* refactor: `Bool` analogue of #2558 * fixed header comment * bug: restored deleted `Nat` operations * bug: restored deleted `Nat` imports * bug: fixed imports after deprecation * bug: fixed imports after deprecation * no properties as such!
1 parent 34f5009 commit 31d59e4

File tree

6 files changed

+87
-16
lines changed

6 files changed

+87
-16
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,19 @@ Deprecated names
5151
∣∣-trans ↦ ∥-trans
5252
```
5353

54+
* In `Data.List.Base`:
55+
```agda
56+
and ↦ Data.Bool.ListAction.and
57+
or ↦ Data.Bool.ListAction.or
58+
any ↦ Data.Bool.ListAction.any
59+
all ↦ Data.Bool.ListAction.all
60+
```
61+
5462
New modules
5563
-----------
5664

65+
* `Data.List.Base.{and|or|any|all}` have been lifted out into `Data.Bool.ListAction`.
66+
5767
Additions to existing modules
5868
-----------------------------
5969

src/Data/Bool/ListAction.agda

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- Booleans: conjunction and disjunction of lists
5+
--
6+
-- Issue #2553: this is a compatibility stub module,
7+
-- ahead of a more thorough refactoring in terms of
8+
-- `Data.List.Effectful.Foldable.foldmap`.
9+
------------------------------------------------------------------------
10+
11+
{-# OPTIONS --cubical-compatible --safe #-}
12+
13+
module Data.Bool.ListAction where
14+
15+
open import Data.Bool.Base using (Bool; _∧_; _∨_; true; false)
16+
open import Data.List.Base using (List; map; foldr)
17+
open import Function.Base using (_∘_)
18+
open import Level
19+
20+
private
21+
variable
22+
a : Level
23+
A : Set a
24+
25+
26+
------------------------------------------------------------------------
27+
-- Definitions
28+
29+
and : List Bool Bool
30+
and = foldr _∧_ true
31+
32+
or : List Bool Bool
33+
or = foldr _∨_ false
34+
35+
any : (A Bool) List A Bool
36+
any p = or ∘ map p
37+
38+
all : (A Bool) List A Bool
39+
all p = and ∘ map p
40+

src/Data/List/Base.agda

+31-13
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ open import Data.Bool.Base as Bool
1616
using (Bool; false; true; not; _∧_; _∨_; if_then_else_)
1717
open import Data.Fin.Base using (Fin; zero; suc)
1818
open import Data.Maybe.Base as Maybe using (Maybe; nothing; just; maybe′)
19-
open import Data.Nat.Base as ℕ using (ℕ; zero; suc; _+_; _*_ ; _≤_ ; s≤s)
19+
open import Data.Nat.Base as ℕ using (ℕ; zero; suc; _+_; _*_)
2020
open import Data.Product.Base as Product using (_×_; _,_; map₁; map₂′)
2121
open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂)
2222
open import Data.These.Base as These using (These; this; that; these)
@@ -150,18 +150,6 @@ null : List A → Bool
150150
null [] = true
151151
null (x ∷ xs) = false
152152

153-
and : List Bool Bool
154-
and = foldr _∧_ true
155-
156-
or : List Bool Bool
157-
or = foldr _∨_ false
158-
159-
any : (A Bool) List A Bool
160-
any p = or ∘ map p
161-
162-
all : (A Bool) List A Bool
163-
all p = and ∘ map p
164-
165153
sum : List ℕ
166154
sum = foldr _+_ 0
167155

@@ -580,3 +568,33 @@ scanl f e (x ∷ xs) = e ∷ scanl f (f e x) xs
580568
"Warning: scanl was deprecated in v2.1.
581569
Please use Data.List.Scans.Base.scanl instead."
582570
#-}
571+
572+
-- Version 2.3
573+
574+
and : List Bool Bool
575+
and = foldr _∧_ true
576+
577+
all : (A Bool) List A Bool
578+
all p = and ∘ map p
579+
{-# WARNING_ON_USAGE and
580+
"Warning: and was deprecated in v2.3.
581+
Please use Data.Bool.ListAction.and instead."
582+
#-}
583+
{-# WARNING_ON_USAGE all
584+
"Warning: all was deprecated in v2.3.
585+
Please use Data.Nat.ListAction.all instead."
586+
#-}
587+
588+
or : List Bool Bool
589+
or = foldr _∨_ false
590+
591+
any : (A Bool) List A Bool
592+
any p = or ∘ map p
593+
{-# WARNING_ON_USAGE or
594+
"Warning: or was deprecated in v2.3.
595+
Please use Data.Bool.ListAction.or instead."
596+
#-}
597+
{-# WARNING_ON_USAGE any
598+
"Warning: any was deprecated in v2.3.
599+
Please use Data.Bool.ListAction.any instead."
600+
#-}

src/Data/List/Relation/Binary/Subset/Propositional/Properties.agda

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ module Data.List.Relation.Binary.Subset.Propositional.Properties
1010
where
1111

1212
open import Data.Bool.Base using (Bool; true; false; T)
13+
open import Data.Bool.ListAction using (any)
1314
open import Data.List.Base
14-
using (List; []; map; _∷_; _++_; concat; concatMap; applyUpTo; any; filter)
15+
using (List; []; map; _∷_; _++_; concat; concatMap; applyUpTo; filter)
1516
open import Data.List.Relation.Unary.Any using (Any; here; there)
1617
open import Data.List.Relation.Unary.All using (All)
1718
import Data.List.Relation.Unary.Any.Properties as Any hiding (filter⁺)

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ module Data.List.Relation.Unary.All.Properties where
1010

1111
open import Axiom.Extensionality.Propositional using (Extensionality)
1212
open import Data.Bool.Base using (Bool; T; true; false)
13+
open import Data.Bool.ListAction using (all)
1314
open import Data.Bool.Properties using (T-∧)
1415
open import Data.Fin.Base using (Fin; zero; suc)
15-
open import Data.List.Base as List hiding (lookup; updateAt)
16+
open import Data.List.Base as List hiding (lookup; updateAt; and; or; all; any)
1617
open import Data.List.Membership.Propositional using (_∈_; _≢∈_)
1718
open import Data.List.Membership.Propositional.Properties
1819
using (there-injective-≢∈; ∈-filter⁻)

src/Data/List/Relation/Unary/Any/Properties.agda

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
module Data.List.Relation.Unary.Any.Properties where
1010

1111
open import Data.Bool.Base using (Bool; false; true; T)
12+
open import Data.Bool.ListAction using (any)
1213
open import Data.Bool.Properties using (T-∨; T-≡)
1314
open import Data.Empty using (⊥)
1415
open import Data.Fin.Base using (Fin; zero; suc)
15-
open import Data.List.Base as List hiding (find)
16+
open import Data.List.Base as List hiding (find; and; or; all; any)
1617
open import Data.List.Effectful as List using (monad)
1718
open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
1819
open import Data.List.Membership.Propositional

0 commit comments

Comments
 (0)