Closed
Description
In Data.List.Base
, I find
filter : ∀ {P : Pred A p} → Decidable P → List A → List A
boolFilter : (A → Bool) → List A → List A
the latter being deprecated.
I am a bit puzzled by this choice. The current version of filter
is simply
filter p = boolFilter (isYes \o p)
I don't question that this specialization gets its own name (as I am generally in favor of fat libraries). However:
- In analogy to the naming conventions of Haskell and OCaml, shouldn't
filter
be theBool
version?
filter : (A → Bool) → List A → List A
- The current filter function (which could be called
decFilter
orfilterDec
) requires a decidable predicate rather than a simple boolean test, but then throws away the evidence. Shouldn't it rather retain the evidence?
decFilter : (p : Decidable P) -> List A -> \Sigma (List A) (All P)
Analogous cases: partition
, span
, break
, takeWhile
, dropWhile
.
Design baseline: Don't ask for data that you don't use to produce the result.
See also #263.