ekmett / kan-extensions

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

Levity polymorphic codensity #48

Closed Icelandjack closed 6 years ago

Icelandjack commented 6 years ago

I doubt this will get accepted, but it's worth noting that Codensity (and similar data types) can be made levity polymorphic

newtype Codensity (m::TYPE rep -> Type) a = Codensity
  { runCodensity :: forall b. (a -> m b) -> m b
  }

If it's worth adding I'll make PR, if I understand correctly it can even be given a kind?

Codensity :: (TYPE rep -> TYPE rep') -> (TYPE rep'' -> Type)
RyanGlScott commented 6 years ago

This was implemented in https://github.com/ekmett/kan-extensions/pull/52.