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 @@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
Breaking changes:

New features:
- Added `bivoid`

Bugfixes:

Expand Down
6 changes: 6 additions & 0 deletions src/Data/Bifunctor.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Control.Category (identity)
import Data.Const (Const(..))
import Data.Either (Either(..))
import Data.Tuple (Tuple(..))
import Data.Unit (Unit, unit)
import Data.Function (const)

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

-- | The bivoid function is used to ignore the types wrapped by a Bifunctor.
bivoid :: forall f a b. Bifunctor f => f a b -> f Unit Unit
bivoid = bimap (const unit) (const unit)

instance bifunctorEither :: Bifunctor Either where
bimap f _ (Left l) = Left (f l)
bimap _ g (Right r) = Right (g r)
Expand Down