Skip to content

Commit 7a60ada

Browse files
authored
Merge pull request #24 from purescript/hoists
Add `hoist` functions
2 parents 3939c48 + e33daf5 commit 7a60ada

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

src/Data/Profunctor/Clown.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ instance functorClown :: Functor (Clown f a) where
2121

2222
instance profunctorClown :: Contravariant f => Profunctor (Clown f) where
2323
dimap f g (Clown a) = Clown (cmap f a)
24+
25+
hoistClown :: forall f g a b. (f ~> g) -> Clown f a b -> Clown g a b
26+
hoistClown f (Clown a) = Clown (f a)

src/Data/Profunctor/Costar.purs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Data.Distributive (class Distributive, distribute)
99
import Data.Either (Either(..), either)
1010
import Data.Functor.Invariant (class Invariant, imapF)
1111
import Data.Newtype (class Newtype)
12-
import Data.Profunctor (class Profunctor)
12+
import Data.Profunctor (class Profunctor, lmap)
1313
import Data.Profunctor.Closed (class Closed)
1414
import Data.Profunctor.Cochoice (class Cochoice)
1515
import Data.Profunctor.Costrong (class Costrong)
@@ -73,3 +73,6 @@ instance cochoiceCostar :: Applicative f => Cochoice (Costar f) where
7373

7474
instance closedCostar :: Functor f => Closed (Costar f) where
7575
closed (Costar f) = Costar \g x -> f (map (_ $ x) g)
76+
77+
hoistCostar :: forall f g a b. (g ~> f) -> Costar f a b -> Costar g a b
78+
hoistCostar f (Costar g) = Costar (lmap f g)

src/Data/Profunctor/Joker.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ instance functorJoker :: Functor f => Functor (Joker f a) where
2020

2121
instance profunctorJoker :: Functor f => Profunctor (Joker f) where
2222
dimap f g (Joker a) = Joker (map g a)
23+
24+
hoistJoker :: forall f g a b. (f ~> g) -> Joker f a b -> Joker g a b
25+
hoistJoker f (Joker a) = Joker (f a)

src/Data/Profunctor/Star.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,6 @@ instance choiceStar :: Applicative f => Choice (Star f) where
7777

7878
instance closedStar :: Distributive f => Closed (Star f) where
7979
closed (Star f) = Star \g -> distribute (f <<< g)
80+
81+
hoistStar :: forall f g a b. (f ~> g) -> Star f a b -> Star g a b
82+
hoistStar f (Star g) = Star (f <<< g)

0 commit comments

Comments
 (0)