You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(/.\) :: Monad m => Bot m s i o -> Bot m s' i o -> Bot m (s /\ s') i o
(/.\) (Bot b1) (Bot b2) = Bot $ \(s1, s2) i -> do
Functor.combine (b1 s1 i, b2 s2 i) >>= \case
This (o, s1') -> pure (o, (s1', s2))
That (o', s2') -> pure (o', (s1, s2'))
These (o, s1') (o', s2') -> toListT [(o, (s1', s2)), (o', (s1', s2'))]
And think that I can replace this with a dimap on a particular Semigroupal instance. In this case it almost works to use Trifunctor.combine @_ @_ @These @These:
(/.\) :: Monad m => Bot m s i o -> Bot m s' i o -> Bot m (s /\ s') i o
(/.\) b1 b2 = dimap (\i -> These i i) _ $ Trifunctor.combine @_ @_ @These @These (b1, b2)
However you end up needing to do something impossible in the rmap side. In this case we need These o o -> o which means discarding an output. The original implementation gets around this because we are binding over the ListT inside the bot.
This exact situation arises often and I'm wondering if there is some other combinator we could leverage or more likely implement that is more powerful then rmap. Maybe some kind of traverse or bind?
We need to be be able to bind over the bot and work with the inner ListT structure (or perhaps even the m inside the ListT?)
I often find myself looking at operations like:
And think that I can replace this with a
dimap
on a particularSemigroupal
instance. In this case it almost works to useTrifunctor.combine @_ @_ @These @These
:However you end up needing to do something impossible in the
rmap
side. In this case we needThese o o -> o
which means discarding an output. The original implementation gets around this because we are binding over theListT
inside the bot.This exact situation arises often and I'm wondering if there is some other combinator we could leverage or more likely implement that is more powerful then
rmap
. Maybe some kind oftraverse
or bind?We need to be be able to bind over the bot and work with the inner
ListT
structure (or perhaps even them
inside theListT
?)@masaeedu
The text was updated successfully, but these errors were encountered: