Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here. What laws do I need for Distributive to make the Category instance below lawful?

data Weirdsli w m a b = Weirdsli { runWeirdsli :: w a -> m b }

class Distributive f g
where
distribute :: f (g a) -> g (f a)

instance (Comonad w, Monad m, Distributive w m) => Category (Weirdsli w m)
where
id = Weirdsli $pure . extract Weirdsli f . Weirdsli g = Weirdsli$ (>>= f) . distribute . (g <<=) The last one can probably be simplified, but here's what I have https://gist.github.com/Lysxia/0f6ef064af8dbf2f39f518d12b77531b

    distribute (fmap_w pure x) = pure x.

fmap_m extract (distribute u) = extract u.

((distribute . (g <<=)) =<< distribute (f <<= x))
=
distribute (((g =<<) . distribute) <<= (f <<= x))

GitHub Gist: instantly share code, notes, and snippets. Code-golfing the last one:

(=<<) (distribute . (<<=) g) . distribute
=
distribute ((<<=) ((=<<) g . distribute)) hmm, very interesting. so the first two are distribute . fmap pure = pure and fmap extract . distribute = extract diagrammatically that's like:

$W \xrightarrow{\rho} W \odot 1 \xrightarrow{1 \odot \eta} W \odot M \xrightarrow{\Delta} M \odot W$

$W \xrightarrow{\lambda} 1 \odot W \xrightarrow{\eta \odot 1} M \odot W$

it's frustratingly close to something like a bimonoid, but it's not quite that you can just write:

math
1 + 1 = 2



and get:

$1 + 1 = 2$