-
Notifications
You must be signed in to change notification settings - Fork 15
add substFreeT #18
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
add substFreeT #18
Conversation
|
||
-- | Like `runFreeT`, but for running into some other FreeT without the | ||
-- | overhead that `MonadRec` incurs. | ||
substFreeT :: forall a m f g. Monad m => Functor g => (f ~> FreeT g m) -> FreeT f m a -> FreeT g m a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: Monad m
is needed because of pure val
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not Applicative
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Monad m => Applicative (FreeT f m)
because Apply is implemented using ap
ping |
Is there any particular blocker for getting this in? if yes can we at least expose constructors from some |
@safareli I'm not familiar with the problem this addition is solving, nor of how to judge whether it's correct. Not because I don't think this is sensible, but simply because I'm not a heavy Also, I'd appreciate hearing about why / whether a test case makes sense for this addition (where could it possibly go wrong? maybe a |
In haskell there is type class MMonad which represents:
Let's look at it's signature, aligned with signature of bind :: forall m a ( a -> m b) -> m a -> m b
embed :: forall m n b t. (forall a. m a -> t n a) -> t m b -> t n b
substFree :: forall m n b (forall a. m a -> Free n a) -> Free m b -> Free n b
substFreeT :: forall m n b g. (forall a. m a -> FreeT n g a) -> FreeT m g b -> FreeT n g b```
Here is example of it's usage: Note: |
There's a corresponding |
yes
|
Ok! Sounds good, thank you @safareli. |
Released as v4.1.0 |
Thanks! |
Adds FreeT version of
substFree :: forall f g. (f ~> Free g) -> Free f ~> Free g