Skip to content

Commit a0d953b

Browse files
m-bockMichael Bock
and
Michael Bock
authored
Add bivoid (#28)
* Add bivoid * Add bivoid to Changelog --------- Co-authored-by: Michael Bock <[email protected]>
1 parent 16ba2fb commit a0d953b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
77
Breaking changes:
88

99
New features:
10+
- Added `bivoid`
1011

1112
Bugfixes:
1213

src/Data/Bifunctor.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Control.Category (identity)
44
import Data.Const (Const(..))
55
import Data.Either (Either(..))
66
import Data.Tuple (Tuple(..))
7+
import Data.Unit (Unit, unit)
8+
import Data.Function (const)
79

810
-- | A `Bifunctor` is a `Functor` from the pair category `(Type, Type)` to `Type`.
911
-- |
@@ -29,6 +31,10 @@ lmap f = bimap f identity
2931
rmap :: forall f a b c. Bifunctor f => (b -> c) -> f a b -> f a c
3032
rmap = bimap identity
3133

34+
-- | The bivoid function is used to ignore the types wrapped by a Bifunctor.
35+
bivoid :: forall f a b. Bifunctor f => f a b -> f Unit Unit
36+
bivoid = bimap (const unit) (const unit)
37+
3238
instance bifunctorEither :: Bifunctor Either where
3339
bimap f _ (Left l) = Left (f l)
3440
bimap _ g (Right r) = Right (g r)

0 commit comments

Comments
 (0)