Skip to content

Commit

Permalink
Merge pull request #24 from purescript/hoists
Browse files Browse the repository at this point in the history
Add `hoist` functions
  • Loading branch information
garyb authored Jun 18, 2017
2 parents 3939c48 + e33daf5 commit 7a60ada
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Data/Profunctor/Clown.purs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ instance functorClown :: Functor (Clown f a) where

instance profunctorClown :: Contravariant f => Profunctor (Clown f) where
dimap f g (Clown a) = Clown (cmap f a)

hoistClown :: forall f g a b. (f ~> g) -> Clown f a b -> Clown g a b
hoistClown f (Clown a) = Clown (f a)
5 changes: 4 additions & 1 deletion src/Data/Profunctor/Costar.purs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Data.Distributive (class Distributive, distribute)
import Data.Either (Either(..), either)
import Data.Functor.Invariant (class Invariant, imapF)
import Data.Newtype (class Newtype)
import Data.Profunctor (class Profunctor)
import Data.Profunctor (class Profunctor, lmap)
import Data.Profunctor.Closed (class Closed)
import Data.Profunctor.Cochoice (class Cochoice)
import Data.Profunctor.Costrong (class Costrong)
Expand Down Expand Up @@ -73,3 +73,6 @@ instance cochoiceCostar :: Applicative f => Cochoice (Costar f) where

instance closedCostar :: Functor f => Closed (Costar f) where
closed (Costar f) = Costar \g x -> f (map (_ $ x) g)

hoistCostar :: forall f g a b. (g ~> f) -> Costar f a b -> Costar g a b
hoistCostar f (Costar g) = Costar (lmap f g)
3 changes: 3 additions & 0 deletions src/Data/Profunctor/Joker.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ instance functorJoker :: Functor f => Functor (Joker f a) where

instance profunctorJoker :: Functor f => Profunctor (Joker f) where
dimap f g (Joker a) = Joker (map g a)

hoistJoker :: forall f g a b. (f ~> g) -> Joker f a b -> Joker g a b
hoistJoker f (Joker a) = Joker (f a)
3 changes: 3 additions & 0 deletions src/Data/Profunctor/Star.purs
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ instance choiceStar :: Applicative f => Choice (Star f) where

instance closedStar :: Distributive f => Closed (Star f) where
closed (Star f) = Star \g -> distribute (f <<< g)

hoistStar :: forall f g a b. (f ~> g) -> Star f a b -> Star g a b
hoistStar f (Star g) = Star (f <<< g)

0 comments on commit 7a60ada

Please sign in to comment.