Skip to content

Commit ccaecd9

Browse files
Merge branch 'master' into experimental
2 parents 21f6e7d + 5cd117b commit ccaecd9

File tree

76 files changed

+2451
-396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2451
-396
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ matrix:
106106

107107
# generating Everything.agda
108108
- cd agda-stdlib
109-
- cabal install lib.cabal
109+
- cabal install agda-stdlib-utils.cabal
110110
- runghc GenerateEverything.hs
111111

112112
# setting up travis-specific scripts and files

AllNonAsciiChars.hs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
1+
{-# LANGUAGE OverloadedStrings #-}
12
-- | This module extracts all the non-ASCII characters used by the
23
-- library code (along with how many times they are used).
34

45
module Main where
56

6-
import qualified Data.List as L
7-
import Data.Char
8-
import Data.Function
9-
import Control.Applicative
10-
import Numeric ( showHex )
11-
import System.FilePath.Find
12-
import System.IO
7+
import qualified Data.List as L (sortBy, group, sort)
8+
import Data.Char (isAscii, ord)
9+
import Data.Function (on)
10+
import Numeric (showHex)
11+
import System.FilePath.Find (find, always, extension, (||?), (==?))
12+
import System.IO (openFile, hSetEncoding, utf8, IOMode(ReadMode))
13+
import qualified Data.Text as T (Text, pack, unpack, concat)
14+
import qualified Data.Text.IO as T (putStrLn, hGetContents)
1315

14-
readUTF8File :: FilePath -> IO String
16+
readUTF8File :: FilePath -> IO T.Text
1517
readUTF8File f = do
1618
h <- openFile f ReadMode
1719
hSetEncoding h utf8
18-
hGetContents h
20+
T.hGetContents h
1921

2022
main :: IO ()
2123
main = do
2224
agdaFiles <- find always
2325
(extension ==? ".agda" ||? extension ==? ".lagda")
2426
"src"
2527
nonAsciiChars <-
26-
filter (not . isAscii) . concat <$> mapM readUTF8File agdaFiles
27-
let table = reverse $
28-
L.sortBy (compare `on` snd) $
28+
filter (not . isAscii) . T.unpack . T.concat <$> mapM readUTF8File agdaFiles
29+
let table :: [(Char, Int)]
30+
table = L.sortBy (flip compare `on` snd) $
2931
map (\cs -> (head cs, length cs)) $
3032
L.group $ L.sort $ nonAsciiChars
3133

32-
let codePoint :: Char -> String
33-
codePoint c = showHex (ord c) ""
34+
let codePoint :: Char -> T.Text
35+
codePoint c = T.pack $ showHex (ord c) ""
3436

35-
uPlus :: Char -> String
36-
uPlus c = "(U+" ++ codePoint c ++ ")"
37+
uPlus :: Char -> T.Text
38+
uPlus c = T.concat ["(U+", codePoint c, ")"]
3739

38-
mapM_ (\(c, count) -> putStrLn (c : " " ++ uPlus c ++ ": " ++ show count))
40+
mapM_ (\(c, count) -> T.putStrLn $ T.concat [T.pack [c], " ", uPlus c, ": ", T.pack $ show count])
3941
table

CHANGELOG.md

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ Highlights
1212
Bug-fixes
1313
---------
1414

15+
* The example module `Maybe` in `Relation.Binary.Construct.Closure.Reflexive` was
16+
accidentally exposed publicly. It has been made private.
17+
18+
* Fixed the type of the proof `map-id` in `List.Relation.Unary.All.Properties`,
19+
which was incorrectly abstracted over unused module parameters.
20+
21+
* Fixed bug where `IsRelIsomorphism` in `Relation.Binary.Morphism.Structures` did not
22+
publicly re-export the contents of `IsRelMonomorphism`.
23+
24+
* The binary relation `_≉_` exposed by records in `Relation.Binary.Bundles` now has
25+
the correct infix precedence.
26+
27+
* Added version to library name
28+
1529
Non-backwards compatible changes
1630
--------------------------------
1731

@@ -46,12 +60,69 @@ Non-backwards compatible changes
4660
`Agda.Builtin.Maybe`. The `Foreign.Haskell` modules and definitions
4761
corresponding to `Maybe` have been removed.
4862

63+
* The internal build utilities package `lib.cabal` has been renamed
64+
`agda-stdlib-utils.cabal` to avoid potential conflict or confusion.
65+
Please note that the package is not intended for external use.
66+
67+
* The module `Algebra.Construct.Zero` and `Algebra.Module.Construct.Zero`
68+
are now level-polymorphic, each taking two implicit level parameters.
69+
70+
* Previously the definition of `_⊖_` in `Data.Integer.Base` was defined
71+
inductively as:
72+
```agda
73+
_⊖_ : ℕ → ℕ → ℤ
74+
m ⊖ ℕ.zero = + m
75+
ℕ.zero ⊖ ℕ.suc n = -[1+ n ]
76+
ℕ.suc m ⊖ ℕ.suc n = m ⊖ n
77+
```
78+
which meant that the unary arguments had to be evaluated. To make it
79+
much faster it's definition has been changed to use operations on ``
80+
that are backed by builtin operations:
81+
```agda
82+
_⊖_ : ℕ → ℕ → ℤ
83+
m ⊖ n with m ℕ.<ᵇ n
84+
... | true = - + (n ℕ.∸ m)
85+
... | false = + (m ℕ.∸ n)
86+
```
87+
4988
Deprecated modules
5089
------------------
5190

91+
* The module `TransitiveClosure` in `Induction.WellFounded` has been deprecated.
92+
You should instead use the standard definition of transitive closure and the
93+
accompanying proof of well-foundness defined in `Relation.Binary.Construct.Closure.Transitive`.
94+
95+
* The module `Relation.Binary.OrderMorphism` has been deprecated, as the new
96+
`(Homo/Mono/Iso)morphism` infrastructure in `Algebra.Morphism.Structures` is now
97+
complete. The new definitions are parameterised by raw bundles instead of bundles
98+
meaning they are much more flexible to work with.
99+
52100
Deprecated names
53101
----------------
54102

103+
* The immediate contents of `Algebra.Morphism` have been deprecated, as the new
104+
`(Homo/Mono/Iso)morphism` infrastructure in `Algebra.Morphism.Structures` is now
105+
complete. The new definitions are parameterised by raw bundles instead of bundles
106+
meaning they are much more flexible to work with. The replacements are as following:
107+
```agda
108+
IsSemigroupMorphism ↦ IsSemigroupHomomorphism
109+
IsMonoidMorphism ↦ IsMonoidHomomorphism
110+
IsCommutativeMonoidMorphism ↦ IsMonoidHomomorphism
111+
IsIdempotentCommutativeMonoidMorphism ↦ IsMonoidHomomorphism
112+
IsGroupMorphism ↦ IsGroupHomomorphism
113+
IsAbelianGroupMorphism ↦ IsGroupHomomorphism
114+
```
115+
116+
* In `Relation.Binary.Construct.Closure.Reflexive`:
117+
```agda
118+
Refl ↦ ReflClosure
119+
```
120+
121+
* In `Relation.Binary.Construct.Closure.Transitive`:
122+
```agda
123+
Plus′ ↦ TransClosure
124+
```
125+
55126
New modules
56127
-----------
57128

@@ -61,6 +132,13 @@ New modules
61132
```
62133
which re-exports and augments the contents of `Agda.Builtin.Reflection.External`.
63134

135+
* Added various generic morphism constructions for binary relations:
136+
```agda
137+
Relation.Binary.Morphism.Construct.Composition
138+
Relation.Binary.Morphism.Construct.Constant
139+
Relation.Binary.Morphism.Construct.Identity
140+
```
141+
64142
* Added `Reflection.Traversal` for generic de Bruijn-aware traversals of reflected terms.
65143
* Added `Reflection.DeBruijn` with weakening, strengthening and free variable operations
66144
on reflected terms.
@@ -72,13 +150,141 @@ New modules
72150

73151
* Added `Relation.Unary.Sized` for unary relations over sized types now that `Size` lives in it's own universe since Agda 2.6.2.
74152

153+
* Added `Relation.Binary.TypeClasses` for type classes to be used with instance search.
154+
* Added various modules containing `instance` declarations:
155+
`Data.Bool.Instances`, `Data.Char.Instances`, `Data.Fin.Instances`,
156+
`Data.Float.Instances`, `Data.Integer.Instances`,
157+
`Data.List.Instances`, `Data.Nat.Instances`,
158+
`Data.Nat.Binary.Instances`, `Data.Product.Instances`,
159+
`Data.Rational.Instances`, `Data.Sign.Instances`,
160+
`Data.String.Instances`, `Data.Sum.Instances`,
161+
`Data.These.Instances`, `Data.Unit.Instances`,
162+
`Data.Unit.Polymorphic.Instances`, `Data.Vec.Instances`,
163+
`Data.Word.Instances`, and `Reflection.Instances`.
164+
165+
* Generic divisibility over algebraic structures
166+
```
167+
Algebra.Divisibility
168+
Algebra.Properties.Magma.Divisibility
169+
Algebra.Properties.Semigroup.Divisibility
170+
Algebra.Properties.Monoid.Divisibility
171+
Algebra.Properties.CommutativeSemigroup.Divisibility
172+
```
173+
75174
Other major changes
76175
-------------------
77176

177+
* The new module `Relation.Binary.TypeClasses` re-exports `_≟_` from
178+
`IsDecEquivalence` and `_≤?_` from `IsDecTotalOrder` where the
179+
principal argument has been made into an instance argument. This
180+
enables automatic resolution if the corresponding module
181+
`Data.*.Instances` (or `Reflection.Instances`) is imported as well.
182+
For example, if `Relation.Binary.TypeClasses`, `Data.Nat.Instances`,
183+
and `Data.Bool.Instances` have been imported, then `true ≟ true` has
184+
type `Dec (true ≡ true)`, while `0 ≟ 1` has type `Dec (0 ≡ 1)`. More
185+
examples can be found in `README.Relation.Binary.TypeClasses`.
186+
78187
Other minor additions
79188
---------------------
80189

81190
* Added new type in `Size`:
82191
```agda
83192
SizedSet ℓ = Size → Set ℓ
84193
```
194+
195+
* All bundles in `Algebra.Bundles` now re-export the binary relation `_≉_` from the underlying `Setoid`.
196+
197+
* Added `Reflection.TypeChecking.Format.errorPartFmt`.
198+
199+
* Added new properties to `Data.List.Properties`:
200+
```agda
201+
concat-++ : concat xss ++ concat yss ≡ concat (xss ++ yss)
202+
concat-concat : concat ∘ map concat ≗ concat ∘ concat
203+
concat-[-] : concat ∘ map [_] ≗ id
204+
```
205+
206+
* Added new records to `Algebra.Bundles`:
207+
```agda
208+
CommutativeMagma c ℓ : Set (suc (c ⊔ ℓ))
209+
RawNearSemiring c ℓ : Set (suc (c ⊔ ℓ))
210+
RawLattice c ℓ : Set (suc (c ⊔ ℓ))
211+
CancellativeCommutativeSemiring c ℓ : Set (suc (c ⊔ ℓ))
212+
```
213+
214+
* Added new definitions to `Algebra.Definitions`:
215+
```agda
216+
AlmostLeftCancellative e _•_ = ∀ {x} y z → ¬ x ≈ e → (x • y) ≈ (x • z) → y ≈ z
217+
AlmostRightCancellative e _•_ = ∀ {x} y z → ¬ x ≈ e → (y • x) ≈ (z • x) → y ≈ z
218+
AlmostCancellative e _•_ = AlmostLeftCancellative e _•_ × AlmostRightCancellative e _•_
219+
```
220+
221+
* Added new records to `Algebra.Morphism.Structures`:
222+
```agda
223+
IsNearSemiringHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂)
224+
IsNearSemiringMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂)
225+
IsNearSemiringIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)
226+
IsSemiringHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂)
227+
IsSemiringMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂)
228+
IsSemiringIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)
229+
IsLatticeHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂)
230+
IsLatticeMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂)
231+
IsLatticeIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)
232+
```
233+
234+
* Added new definitions to `Algebra.Structures`:
235+
```agda
236+
IsCommutativeMagma (• : Op₂ A) : Set (a ⊔ ℓ)
237+
IsCancellativeCommutativeSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ)
238+
```
239+
240+
* Added new proofs in `Data.Integer.Properties`:
241+
```agda
242+
[1+m]⊖[1+n]≡m⊖n : suc m ⊖ suc n ≡ m ⊖ n
243+
⊖-≤ : m ≤ n → m ⊖ n ≡ - + (n ∸ m)
244+
-m+n≡n⊖m : - (+ m) + + n ≡ n ⊖ m
245+
m-n≡m⊖n : + m + (- + n) ≡ m ⊖ n
246+
```
247+
248+
* Added new definition in `Data.Nat.Base`:
249+
```agda
250+
_≤ᵇ_ : (m n : ℕ) → Bool
251+
```
252+
253+
* Added new proofs in `Data.Nat.Properties`:
254+
```agda
255+
≤ᵇ⇒≤ : T (m ≤ᵇ n) → m ≤ n
256+
≤⇒≤ᵇ : m ≤ n → T (m ≤ᵇ n)
257+
258+
<ᵇ-reflects-< : Reflects (m < n) (m <ᵇ n)
259+
≤ᵇ-reflects-≤ : Reflects (m ≤ n) (m ≤ᵇ n)
260+
```
261+
262+
* Added new proof in `Relation.Nullary.Reflects`:
263+
```agda
264+
fromEquivalence : (T b → P) → (P → T b) → Reflects P b
265+
```
266+
267+
* Add new properties to `Data.Vec.Properties`:
268+
```agda
269+
take-distr-zipWith : take m (zipWith f u v) ≡ zipWith f (take m u) (take m v)
270+
take-distr-map : take m (map f v) ≡ map f (take m v)
271+
drop-distr-zipWith : drop m (zipWith f u v) ≡ zipWith f (drop m u) (drop m v)
272+
drop-distr-map : drop m (map f v) ≡ map f (drop m v)
273+
take-drop-id : take m v ++ drop m v ≡ v
274+
zipWith-replicate : zipWith {n = n} _⊕_ (replicate x) (replicate y) ≡ replicate (x ⊕ y)
275+
```
276+
277+
* Added new proofs to `Relation.Binary.Construct.Closure.Transitive`:
278+
```agda
279+
reflexive : Reflexive _∼_ → Reflexive _∼⁺_
280+
symmetric : Symmetric _∼_ → Symmetric _∼⁺_
281+
transitive : Transitive _∼⁺_
282+
wellFounded : WellFounded _∼_ → WellFounded _∼⁺_
283+
```
284+
285+
* Add new properties to `Data.Integer.Properties`:
286+
```agda
287+
+-*-commutativeSemiring : CommutativeSemiring 0ℓ 0ℓ
288+
```
289+
290+
* Added infix declarations to `Data.Product.∃-syntax` and `Data.Product.∄-syntax`.

GenerateEverything.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ unsafeModules = map modToFile
4343
, "Relation.Binary.PropositionalEquality.TrustMe"
4444
, "Text.Pretty.Core"
4545
, "Text.Pretty"
46-
] where
46+
]
4747

4848
isUnsafeModule :: FilePath -> Bool
4949
isUnsafeModule fp =
@@ -160,13 +160,13 @@ classify fp hd ls
160160

161161
-- based on detected comment in header
162162
deprecated = let detect = List.isSubsequenceOf "This module is DEPRECATED."
163-
in not $ null $ filter detect hd
163+
in any detect hd
164164

165165
-- GA 2019-02-24: note that we do not reprocess the whole module for every
166166
-- option check: the shared @options@ definition ensures we only inspect a
167167
-- handful of lines (at most one, ideally)
168168
option str = let detect = List.isSubsequenceOf ["{-#", "OPTIONS", str, "#-}"]
169-
in not $ null $ filter detect options
169+
in any detect options
170170
options = words <$> filter (List.isInfixOf "OPTIONS") ls
171171

172172
-- formatting error messages
@@ -277,7 +277,7 @@ usage = unlines
277277
-- | Formats the extracted module information.
278278

279279
format :: [LibraryFile] -> String
280-
format = unlines . concat . map fmt
280+
format = unlines . concatMap fmt
281281
where
282282
fmt lf = "" : header lf ++ ["import " ++ fileToMod (filepath lf)]
283283

0 commit comments

Comments
 (0)