Skip to content

Commit

Permalink
Some properties of Data.List.gfilter.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed Jan 23, 2015
1 parent 25b6065 commit 131e69d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Data/List/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,24 @@ filter-filters P dec (x ∷ xs) with dec x
filter-filters P dec (x ∷ xs) | yes px = px ∷ filter-filters P dec xs
filter-filters P dec (x ∷ xs) | no ¬px = filter-filters P dec xs

-- Gfilter.

gfilter-just : {a} {A : Set a} (xs : List A) gfilter just xs ≡ xs
gfilter-just [] = refl
gfilter-just (x ∷ xs) = P.cong (_∷_ x) (gfilter-just xs)

gfilter-nothing : {a} {A : Set a} (xs : List A)
gfilter {B = A} (λ _ nothing) xs ≡ []
gfilter-nothing [] = refl
gfilter-nothing (x ∷ xs) = gfilter-nothing xs

gfilter-concatMap : {a b} {A : Set a} {B : Set b} (f : A Maybe B)
gfilter f ≗ concatMap (fromMaybe ∘ f)
gfilter-concatMap f [] = refl
gfilter-concatMap f (x ∷ xs) with f x
gfilter-concatMap f (x ∷ xs) | just y = P.cong (_∷_ y) (gfilter-concatMap f xs)
gfilter-concatMap f (x ∷ xs) | nothing = gfilter-concatMap f xs

-- Inits, tails, and scanr.

scanr-defn : {a b} {A : Set a} {B : Set b}
Expand Down

0 comments on commit 131e69d

Please sign in to comment.