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 <<=)
What laws do I need for
Distributive
to make theCategory
instance below lawful?The last one can probably be simplified, but here's what I have https://gist.github.com/Lysxia/0f6ef064af8dbf2f39f518d12b77531b
Code-golfing the last one:
hmm, very interesting. so the first two are
distribute . fmap pure = pure
andfmap extract . distribute = extract
diagrammatically that's like:
WρW⊙11⊙ηW⊙MΔM⊙W
Wλ1⊙Wη⊙1M⊙W
it's frustratingly close to something like a bimonoid, but it's not quite that
how did you make this diagram
you can just write:
and get:
1+1=2
btw you can look at the source for anyone's comments, there's a little menu on the right
wow
til. thanks!
This is really cool! (Especially the source view feature!) Thanks!
You're a wizard.
Someone post this in fpslack :-P