This question deals with constructing a proper Monad
instance from something that is a monad, but only under certain constraints - for example Set
. The trick is to wrap it into ContT
, which defers the constraints to wrapping/unwrapping its values.
Now I'd like to do the same with Applicative
s. In particular, I have an Applicative
instance whose pure has a type-class constraint. Is there a similar trick how to construct a valid Applicative
instance?
(Is there "the mother of all applicative functors" just as there is for monads?)
I'm not sure the notion of "restricted applicative" is unique, as different presentations are not isomorphic. That said here is one and something at least somewhat along the lines of Codensity. The idea is to have a "free functor" together with a unit
EDIT: Fixed some bugs. That is what happens when you don't compile before posting.