Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ New features:
Bugfixes:

Other improvements:
- Fix UnusedName warnings revealed by v0.14.1 PS release (#22 by @JordanMartinez)

## [v4.0.0](https://github.com/purescript/purescript-filterable/releases/tag/v4.0.0) - 2021-03-07

Expand Down
6 changes: 3 additions & 3 deletions src/Data/Filterable.purs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ instance filterableArray :: Filterable Array where
filter = Array.filter

instance filterableMaybe :: Filterable Maybe where
partitionMap p Nothing = { left: Nothing, right: Nothing }
partitionMap _ Nothing = { left: Nothing, right: Nothing }
partitionMap p (Just x) = case p x of
Left a -> { left: Just a, right: Nothing }
Right b -> { left: Nothing, right: Just b }
Expand All @@ -169,14 +169,14 @@ instance filterableMaybe :: Filterable Maybe where
filter p = filterDefault p

instance filterableEither :: Monoid m => Filterable (Either m) where
partitionMap p (Left x) = { left: Left x, right: Left x }
partitionMap _ (Left x) = { left: Left x, right: Left x }
partitionMap p (Right x) = case p x of
Left a -> { left: Right a, right: Left mempty }
Right b -> { left: Left mempty, right: Right b }

partition p = partitionDefault p

filterMap p (Left l) = Left l
filterMap _ (Left l) = Left l
filterMap p (Right r) = case p r of
Nothing -> Left mempty
Just x -> Right x
Expand Down
8 changes: 4 additions & 4 deletions src/Data/Witherable.purs
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,21 @@ instance witherableMap :: Ord k => Witherable (Map.Map k) where
) <$> acc <*> p x

instance witherableMaybe :: Witherable Maybe where
wilt p Nothing = pure { left: Nothing, right: Nothing }
wilt _ Nothing = pure { left: Nothing, right: Nothing }
wilt p (Just x) = map convert (p x) where
convert (Left l) = { left: Just l, right: Nothing }
convert (Right r) = { left: Nothing, right: Just r }

wither p Nothing = pure Nothing
wither _ Nothing = pure Nothing
wither p (Just x) = p x

instance witherableEither :: Monoid m => Witherable (Either m) where
wilt p (Left el) = pure { left: Left el, right: Left el }
wilt _ (Left el) = pure { left: Left el, right: Left el }
wilt p (Right er) = map convert (p er) where
convert (Left l) = { left: Right l, right: Left mempty }
convert (Right r) = { left: Left mempty, right: Right r }

wither p (Left el) = pure (Left el)
wither _ (Left el) = pure (Left el)
wither p (Right er) = map convert (p er) where
convert Nothing = Left mempty
convert (Just r) = Right r