Comux - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Asad Saeeduddin

Is there a way to prove this class can't be implemented:

class Profunctor p => Comux p
  where
  comux :: p (a, b) (c, d) -> (p a c, p b d)
TheMatten

@Asad Saeeduddin I guess there isn't:

newtype ConstId a b = ConstId b deriving Show

instance Profunctor ConstId where
  dimap _ f (ConstId c) = ConstId $ f c

instance Comux ConstId where
  comux (ConstId (c, d)) = (ConstId c, ConstId d)
Asad Saeeduddin

Good thinking! I suppose that means it works for data Joker f a b = Joker (f b) as well

Asad Saeeduddin

when f is Alternative, is Joker f a Category?

TheMatten

Hmm, the left-most morphism will always have to win, so I guess it would be lawful?

Asad Saeeduddin

I think it can be a semigroupoid but not a category

Asad Saeeduddin

For the same reason data Const a b = a can't be a monoid

TheMatten

Why Const isn't monoid?

Asad Saeeduddin

well, the semigroup works like this: x <> _ = x

TheMatten

What if I used Monoid a constraint instead?

TheMatten

basically like Identity instance

Asad Saeeduddin

yes, it would work then. unfortunately we can't pull the same trick for Category, because it needs to be parametric in a and b