Skip to content

[ refactor ] change type of Data.Vec.Base.{truncate|padRight} #2770

@jamesmckinna

Description

@jamesmckinna

The types of these two operations (introduced in #1640 ) are too strict in their m ≤ n argument, when this could be made irrelevant:

------------------------------------------------------------------------
-- Operations involving ≤

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

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

A non-breaking change, because every existing call site will have the same form as now, even though the type is strictly more constrained?

So: should we make it for v2.x, in view of #2769 or wait for v3.0?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions