Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

free: hoistCofree should be generalized #5

Open
Gurkenglas opened this issue Mar 19, 2016 · 4 comments
Open

free: hoistCofree should be generalized #5

Gurkenglas opened this issue Mar 19, 2016 · 4 comments

Comments

@Gurkenglas
Copy link
Collaborator

It currently has type

Functor f => (forall x. f x -> g x) -> Cofree f a -> Cofree g a

It could have type

Functor f => (f (Cofree g a) -> g (Cofree g a)) -> Cofree f a -> Cofree g a

This would allow me to write things like

import qualified Data.Foldable as F
braid :: Monad m => Cofree m a -> [m a]
braid = F.toList . hoistCofree (Identity . join) . return
@neongreen
Copy link
Member

Made a pull request: ekmett/free#131

@fumieval
Copy link

fumieval commented Apr 6, 2016

I think we deliberately use (forall x . f x -> g x) to allow only "legal" transformations.

@neongreen
Copy link
Member

Okay, makes sense to me. @Gurkenglas, can this be closed?

@neongreen
Copy link
Member

(There's a longer explanation here: ekmett/free#131 (comment).)

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

No branches or pull requests

3 participants