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

hoistFree should be named transFree #228

Open
ncfavier opened this issue Feb 18, 2023 · 0 comments
Open

hoistFree should be named transFree #228

ncfavier opened this issue Feb 18, 2023 · 0 comments

Comments

@ncfavier
Copy link

ncfavier commented Feb 18, 2023

-- | Lift a natural transformation from @f@ to @g@ into a natural transformation from @'Free' f@ to @'Free' g@.
hoistFree :: Functor g => (forall a. f a -> g a) -> Free f b -> Free g b

-- | Lift a monad homomorphism from @m@ to @n@ into a monad homomorphism from @'FreeT' f m@ to @'FreeT' f n@
--
-- @'hoistFreeT' :: ('Functor' m, 'Functor' f) => (m ~> n) -> 'FreeT' f m ~> 'FreeT' f n@
hoistFreeT :: (Functor m, Functor f) => (forall a. m a -> n a) -> FreeT f m b -> FreeT f n b

-- | Lift a natural transformation from @f@ to @g@ into a monad homomorphism from @'FreeT' f m@ to @'FreeT' g m@
transFreeT :: (Monad m, Functor g) => (forall a. f a -> g a) -> FreeT f m b -> FreeT g m b

Both hoistFree and transFreeT correspond to lifting a natural transformation f ⇒ g to a monad homomorphism Free f ⇒ Free g, just like you'd lift a function a → b to a monoid homomorphism [a] → [b]. hoistFreeT is specific to monad transformers.

hoistFree should be deprecated and renamed to transFree, and its comment should mention that it lifts a natural transformation to a monad homomorphism.

Same thing with hoistF/hoistFT/transFT and possibly others.

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

1 participant