File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,28 @@ open import Haskell.Prelude
44
55open import Haskell.Data.Ord using (comparing)
66
7+ open import Haskell.Law.Eq
8+ open import Haskell.Law.Equality
9+
710{-----------------------------------------------------------------------------
811 Operations
912------------------------------------------------------------------------------}
1013
1114partition : (a → Bool) → List a → (List a × List a)
1215partition p xs = (filter p xs , filter (not ∘ p) xs)
1316
17+ -- | Delete all occurrences of an item.
18+ -- Not part of 'Data.List'.
19+ deleteAll : ⦃ _ : Eq a ⦄ → @0 ⦃ IsLawfulEq a ⦄ → a → List a → List a
20+ deleteAll x = filter (not ∘ (x ==_))
21+
22+ -- | These semantics of 'nub' assume that the 'Eq' instance
23+ -- is lawful.
24+ -- These semantics are inefficient, but good for proofs.
25+ nub : ⦃ _ : Eq a ⦄ → @0 ⦃ IsLawfulEq a ⦄ → List a → List a
26+ nub [] = []
27+ nub (x ∷ xs) = x ∷ deleteAll x (nub xs)
28+
1429postulate
1530 sortBy : (a → a → Ordering) → List a → List a
1631
You can’t perform that action at this time.
0 commit comments