diff --git a/CHANGELOG.md b/CHANGELOG.md index f3f815a..d0808b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Breaking changes: New features: Bugfixes: +- `splitStrong` and `splitChoice` functions as not requiring `identity` have now relaxed constrain of `Semigroupoid` instead of `Catergory`. Other improvements: diff --git a/src/Data/Profunctor/Choice.purs b/src/Data/Profunctor/Choice.purs index 5ce5641..2003445 100644 --- a/src/Data/Profunctor/Choice.purs +++ b/src/Data/Profunctor/Choice.purs @@ -3,7 +3,7 @@ module Data.Profunctor.Choice where import Prelude import Data.Either (Either(..), either) -import Data.Profunctor (class Profunctor, dimap) +import Data.Profunctor (class Profunctor, rmap) -- | The `Choice` class extends `Profunctor` with combinators for working with -- | sum types. @@ -46,7 +46,7 @@ instance choiceFn :: Choice (->) where -- | `bi-map` would do for the `bi-functor` instance of `Either`. splitChoice :: forall p a b c d - . Category p + . Semigroupoid p => Choice p => p a b -> p c d @@ -73,14 +73,11 @@ infixr 2 splitChoice as +++ -- | function which will run the approriate computation based on the parameter supplied in the `Either` value. fanin :: forall p a b c - . Category p + . Semigroupoid p => Choice p => p a c -> p b c -> p (Either a b) c -fanin l r = (l +++ r) >>> join - where - join :: p (Either c c) c - join = dimap (either identity identity) identity identity +fanin l r = rmap (either identity identity) (l +++ r) infixr 2 fanin as ||| diff --git a/src/Data/Profunctor/Strong.purs b/src/Data/Profunctor/Strong.purs index 847c8da..1b4784d 100644 --- a/src/Data/Profunctor/Strong.purs +++ b/src/Data/Profunctor/Strong.purs @@ -2,7 +2,7 @@ module Data.Profunctor.Strong where import Prelude -import Data.Profunctor (class Profunctor, dimap) +import Data.Profunctor (class Profunctor, lcmap) import Data.Tuple (Tuple(..)) -- | The `Strong` class extends `Profunctor` with combinators for working with @@ -45,7 +45,7 @@ instance strongFn :: Strong (->) where -- | would do for the `bi-functor` instance of `Tuple`. splitStrong :: forall p a b c d - . Category p + . Semigroupoid p => Strong p => p a b -> p c d @@ -70,14 +70,11 @@ infixr 3 splitStrong as *** -- | on the same input and return both results in a `Tuple`. fanout :: forall p a b c - . Category p + . Semigroupoid p => Strong p => p a b -> p a c -> p a (Tuple b c) -fanout l r = split >>> (l *** r) - where - split :: p a (Tuple a a) - split = dimap identity (\a -> Tuple a a) identity +fanout l r = lcmap (\a -> Tuple a a) (l *** r) infixr 3 fanout as &&&