diff --git a/CHANGELOG.md b/CHANGELOG.md index 79b5a88..54cdd33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/src/Data/Bifunctor.purs b/src/Data/Bifunctor.purs index c254aea..8328732 100644 --- a/src/Data/Bifunctor.purs +++ b/src/Data/Bifunctor.purs @@ -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`. -- | @@ -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)