-
Notifications
You must be signed in to change notification settings - Fork 264
On filter and boolFilter #920
Copy link
Copy link
Closed
Labels
Milestone
Description
In Data.List.Base, I find
filter : ∀ {P : Pred A p} → Decidable P → List A → List A
boolFilter : (A → Bool) → List A → List Athe 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
filterbe theBoolversion?
filter : (A → Bool) → List A → List A- The current filter function (which could be called
decFilterorfilterDec) 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.
Reactions are currently unavailable