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

Breaking changes:
- Added support for PureScript 0.14 and dropped support for all previous versions (#16)
- Ported `Clown`, `Joker`, and `Product` to `purescript-functors` (#21)

New features:

Expand Down
15 changes: 15 additions & 0 deletions src/Data/Bifunctor.purs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module Data.Bifunctor where

import Data.Functor (class Functor, map)
import Data.Functor.Clown (Clown(..))
import Data.Functor.Joker (Joker(..))
import Data.Functor.Product2 (Product2(..))
import Control.Biapplicative (class Biapplicative, bipure)
import Control.Biapply (class Biapply, biapply)
import Control.Category (identity)

-- | A `Bifunctor` is a `Functor` from the pair category `(Type, Type)` to `Type`.
Expand All @@ -18,6 +24,15 @@ import Control.Category (identity)
class Bifunctor f where
bimap :: forall a b c d. (a -> b) -> (c -> d) -> f a c -> f b d

instance bifunctorClown :: Functor f => Bifunctor (Clown f) where
bimap f _ (Clown a) = Clown (map f a)

instance bifunctorJoker :: Functor g => Bifunctor (Joker g) where
bimap _ g (Joker a) = Joker (map g a)

instance bifunctorProduct2 :: (Bifunctor f, Bifunctor g) => Bifunctor (Product2 f g) where
bimap f g (Product2 x y) = Product2 (bimap f g x) (bimap f g y)

-- | Map a function over the first type argument of a `Bifunctor`.
lmap :: forall f a b c. Bifunctor f => (a -> b) -> f a c -> f b c
lmap f = bimap f identity
Expand Down
34 changes: 0 additions & 34 deletions src/Data/Bifunctor/Clown.purs

This file was deleted.

34 changes: 0 additions & 34 deletions src/Data/Bifunctor/Joker.purs

This file was deleted.

28 changes: 0 additions & 28 deletions src/Data/Bifunctor/Product.purs

This file was deleted.