Skip to content

Commit cd7963b

Browse files
authored
[ add ] concat [ xs ] ≡ xs (agda#2530)
* add: `concat-[_]` * refactor: rename+deprecate * refactor: knock-on viscosity * `List` instead of `Vec`! * deprecate old name!
1 parent ecd3b06 commit cd7963b

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ Deprecated names
7676
normalise-correct ↦ Algebra.Solver.Monoid.Normal.correct
7777
```
7878

79+
* In `Data.List.Properties`:
80+
```agda
81+
concat-[-] ↦ concat-map-[_]
82+
```
83+
7984
* In `Data.List.Relation.Binary.Permutation.Setoid.Properties`:
8085
```agda
8186
split ↦ ↭-split
@@ -318,6 +323,7 @@ Additions to existing modules
318323
```agda
319324
product≢0 : All NonZero ns → NonZero (product ns)
320325
∈⇒≤product : All NonZero ns → n ∈ ns → n ≤ product ns
326+
concat-[_] : concat ∘ [_] ≗ id
321327
concatMap-++ : concatMap f (xs ++ ys) ≡ concatMap f xs ++ concatMap f ys
322328
filter-≐ : P ≐ Q → filter P? ≗ filter Q?
323329

src/Data/List/Properties.agda

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,12 @@ concat-concat (xss ∷ xsss) = begin
677677
concat xss ++ concat (concat xsss) ≡⟨ concat-++ xss (concat xsss) ⟩
678678
concat (concat (xss ∷ xsss)) ∎
679679

680-
concat-[-] : concat {A = A} ∘ map [_] ≗ id
681-
concat-[-] [] = refl
682-
concat-[-] (x ∷ xs) = cong (x ∷_) (concat-[-] xs)
680+
concat-map-[_] : concat {A = A} ∘ map [_] ≗ id
681+
concat-map-[ [] ] = refl
682+
concat-map-[ x ∷ xs ] = cong (x ∷_) (concat-map-[ xs ])
683+
684+
concat-[_] : concat {A = A} ∘ [_] ≗ id
685+
concat-[ xs ] = ++-identityʳ xs
683686

684687
------------------------------------------------------------------------
685688
-- concatMap
@@ -688,7 +691,7 @@ concatMap-cong : ∀ {f g : A → List B} → f ≗ g → concatMap f ≗ concat
688691
concatMap-cong eq = cong concat ∘ map-cong eq
689692

690693
concatMap-pure : concatMap {A = A} [_] ≗ id
691-
concatMap-pure = concat-[-]
694+
concatMap-pure = concat-map-[_]
692695

693696
concatMap-map : (g : B List C) (f : A B)
694697
concatMap g ∘′ (map f) ≗ concatMap (g ∘′ f)
@@ -1647,3 +1650,11 @@ scanl-defn f e (x ∷ xs) = cong (e ∷_) (begin
16471650
"Warning: scanl-defn was deprecated in v2.1.
16481651
Please use Data.List.Scans.Properties.scanl-defn instead."
16491652
#-}
1653+
1654+
-- Version 2.2
1655+
1656+
concat-[-] = concat-map-[_]
1657+
{-# WARNING_ON_USAGE concat-[-]
1658+
"Warning: concat-[-] was deprecated in v2.2.
1659+
Please use concat-map-[_] instead."
1660+
#-}

src/Data/List/Sort/MergeSort.agda

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Data.List.Sort.MergeSort
1717
open import Data.Bool.Base using (true; false)
1818
open import Data.List.Base
1919
using (List; []; _∷_; merge; length; map; [_]; concat; _++_)
20-
open import Data.List.Properties using (length-partition; ++-assoc; concat-[-])
20+
open import Data.List.Properties using (length-partition; ++-assoc; concat-map-[_])
2121
open import Data.List.Relation.Unary.Linked using ([]; [-])
2222
import Data.List.Relation.Unary.Sorted.TotalOrder.Properties as Sorted
2323
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
@@ -86,7 +86,7 @@ mergeAll-↭ (xs ∷ ys ∷ xss) (acc rec) = begin
8686
sort-↭ : xs sort xs ↭ xs
8787
sort-↭ xs = begin
8888
mergeAll (map [_] xs) _ ↭⟨ mergeAll-↭ (map [_] xs) _ ⟩
89-
concat (map [_] xs) ≡⟨ concat-[-] xs ⟩
89+
concat (map [_] xs) ≡⟨ concat-map-[ xs ]
9090
xs ∎
9191

9292
------------------------------------------------------------------------

0 commit comments

Comments
 (0)