ekmett / kan-extensions

Kan extensions, Kan lifts, the Yoneda lemma, and (co)monads generated by a functor
Other
78 stars 33 forks source link

Consider different functor arguments of Ran, Lan #41

Open Icelandjack opened 7 years ago

Icelandjack commented 7 years ago

There is some talk on reddit if the functor arguments of Ran, Lan should be swapped, for example defining ibind and iextend for them

ibind :: (a -> Ran k j b) -> (Ran j i a -> Ran k i b)
ibind k (Ran m) = Ran (\c -> m (\a -> runRan (k a) c))

iextend :: (Lan k j a -> b) -> (Lan k i a -> Lan j i b)
iextend f (Lan h ws) = Lan (f . Lan h) ws

yields a swapped argument order from the type class

class IxApplicative m => IxMonad m where
  ibind :: (a -> m j k b) -> (m i j a -> m i k b)

class IxCopointed w => IxComonad w where
  iextend :: (w j k a -> b) -> (w i k a -> w i j b)

Thoughts?

Icelandjack commented 7 years ago

A counter point is that the normal argument order allows for a Profunctor1 instance

class Profunctor1 p where
  dimap1 :: (f' ~> f) -> (g ~> g') -> (p f g ~> p f' g')

instance Profunctor1 Ran where
  dimap1 :: (f' ~> f) -> (g ~> g') -> (Ran f g ~> Ran f' g')
  dimap1 f g (Ran h) = Ran $ \i -> g (h (f . i))