Skip to content

Commit 9f1fc8b

Browse files
committed
Add Endo style instances for Join
1 parent b9dc6ce commit 9f1fc8b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Data/Profunctor/Join.purs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Prelude
55
import Data.Functor.Invariant (class Invariant)
66
import Data.Newtype (class Newtype)
77
import Data.Profunctor (class Profunctor, dimap)
8+
import Data.Monoid (class Monoid)
89

910
-- | Turns a `Profunctor` into a `Invariant` functor by equating the two type
1011
-- | arguments.
@@ -17,5 +18,11 @@ derive newtype instance ordJoin :: Ord (p a a) => Ord (Join p a)
1718
instance showJoin :: Show (p a a) => Show (Join p a) where
1819
show (Join x) = "(Join " <> show x <> ")"
1920

21+
instance semigroupJoin :: Semigroupoid p => Semigroup (Join p a) where
22+
append (Join a) (Join b) = Join (a <<< b)
23+
24+
instance monoidJoin :: Category p => Monoid (Join p a) where
25+
mempty = Join id
26+
2027
instance invariantJoin :: Profunctor p => Invariant (Join p) where
2128
imap f g (Join a) = Join (dimap g f a)

0 commit comments

Comments
 (0)