Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better roles for Control.Monad.Trans.Free.Church.F #86

Closed
ekmett opened this issue Mar 11, 2015 · 1 comment
Closed

Better roles for Control.Monad.Trans.Free.Church.F #86

ekmett opened this issue Mar 11, 2015 · 1 comment

Comments

@ekmett
Copy link
Owner

ekmett commented Mar 11, 2015

We wind up with a nominal role for the 'm' parameter, because it occurs inside f in the body of FT

newtype FT f m a = FT { runFT :: forall r. (a -> m r) -> (f (m r) -> m r) -> m r }

We should be able to achieve representational by smashing that occurrence of f with Yoneda.

newtype FT f m a = FT { runFT :: forall r. (a -> m r) -> (forall x. (x -> m r) -> f x -> m r) -> m r }

This is the same trick that drives the Mendler-style catamorphism.

@masaeedu
Copy link

@ekmett Just for my own edification, wouldn't "smashing the occurrence of f" involve the following conversion?

fwd :: Functor f => f x -> (forall y. (x -> y) -> f y)
fwd fx = \xy -> fmap xy fx

If we're smashing f (m r) specifically, plug and chugging converts the following:

newtype FT f m a = FT { runFT :: forall r. (a -> m r) -> (f (m r) -> m r) -> m r }

to:

newtype FT f m a = FT { runFT :: forall r. (a -> m r) -> ((forall x. ((m r) -> x) -> f x) -> m r) -> m r }

Is there some further isomorphism that produces the type you have above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants