adjunctions icon indicating copy to clipboard operation
adjunctions copied to clipboard

Define 'Representable (Join f)' once we have Bicomonad

Open Icelandjack opened this issue 6 years ago • 1 comments

For future reference, once we have Bicomonad

class Bifunctor bi => Bicomonad bi where
  fst :: bi a b -> a
  snd :: bi a b -> b

  bidup :: bi a b -> (bi a b `bi` bi a b)

I think we can define a Representable instance for (Join f)

instance (Biapplicative f, Bicomonad f) => Representable (Join f) where
  type Rep (Join f) = Bool

  index :: Join f a -> (Bool -> a)
  index (Join faa) = \case
    False -> fst faa
    True  -> snd faa

  tabulate :: (Bool -> a) -> Join f a
  tabulate gen = Join (False `bipure` True)

unless it's unlawful. It captures the pattern of Representable Pair for newtype Pair a = Pair (a, a).

Icelandjack avatar Mar 30 '18 22:03 Icelandjack

Or some hypothetical Bipointed, Bicopointed.

Icelandjack avatar Mar 30 '18 22:03 Icelandjack