Skip to content

Commit 3c9a5f4

Browse files
committed
refactor: make truncate and padRight take irrelevant argument
1 parent 0e97e2e commit 3c9a5f4

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Non-backwards compatible changes
1515
Minor improvements
1616
------------------
1717

18+
* The types of `Data.Vec.Base.{truncate|padRight}` have been weakened so
19+
that the argument of type `m ≤ n` is marked as irrelevant. This should be
20+
backwards compatible, but does change the equational behaviour of these
21+
functions to be more eager, because no longer blocking on pattern matching
22+
on that argument.
23+
1824
Deprecated modules
1925
------------------
2026

src/Data/Vec/Base.agda

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,14 @@ uncons (x ∷ xs) = x , xs
289289
-- Operations involving ≤
290290

291291
-- Take the first 'm' elements of a vector.
292-
truncate : {m n} m ≤ n Vec A n Vec A m
293-
truncate {m = zero} _ _ = []
294-
truncate (s≤s le) (x ∷ xs) = x ∷ (truncate le xs)
292+
truncate : .(m ≤ n) Vec A n Vec A m
293+
truncate {m = zero} _ _ = []
294+
truncate {m = suc _} le (x ∷ xs) = x ∷ (truncate (s≤s⁻¹ le) xs)
295295

296296
-- Pad out a vector with extra elements.
297-
padRight : {m n} m ≤ n A Vec A m Vec A n
298-
padRight z≤n a xs = replicate _ a
299-
padRight (s≤s le) a (x ∷ xs) = x ∷ padRight le a xs
297+
padRight : .(m ≤ n) A Vec A m Vec A n
298+
padRight {n = _} _ a [] = replicate _ a
299+
padRight {n = suc _} le a (x ∷ xs) = x ∷ padRight (s≤s⁻¹ le) a xs
300300

301301
------------------------------------------------------------------------
302302
-- Operations for converting between lists

0 commit comments

Comments
 (0)