-
Notifications
You must be signed in to change notification settings - Fork 15
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 CofreeT #26
Add CofreeT #26
Conversation
I'm not familiar enough with CofreeT to comment on this. Overall, it looks like the initial PR is good. My guess is that we're not looking for the most performant implementation of this, or even the most complete implementation; merely, an implementation in the first place, correct? |
Alright, thank you for the feedback. I'll proceed to add docs, tests, etc., as to make it ready for review/merge! |
I have no idea how to write unit tests for Note that, despite me having added a file under I think this is now ready for review! |
LGTM. The docs helped me understand why I would use this, so thanks! |
I'll have time to review this certainly by the end of the week. Thanks for the PR! |
I realised I might want to do one more thing: consider what other instances I could add to EDIT: nevermind, they are done 👇 |
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.
I'm not particularly familiar with Cofree
, so it would be nice to have another look from @garyb (if you have a moment or suggestions for anyone else who should verify this). That said, it looks pretty good to me! Just a couple of suggestions.
There is also this implementation which relies on |
I addressed all review comments. About the |
No need to introduce it, although since we’re already bringing in new dependencies it wouldn’t be that big of a deal. I’d like to let this sit for a week or so for others to weigh in, but if no one does by then I will go ahead and merge because it appears correct to me (with the caveat that I’m not particularly familiar with this construct). |
src/Control/Monad/Cofree/Trans.purs
Outdated
instance comonadCofreeT :: (Comonad m, Functor f) => Comonad (CofreeT f m) where | ||
extract = extract <<< head | ||
|
||
instance eqCofreeT :: Eq (m (Tuple a (f (CofreeT f m a)))) => Eq (CofreeT f m a) where |
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.
This won't be guaranteed to terminate in most actual use cases. Is there a reason for adding it?
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.
Is it because we expect CofreeT
s to generally be infinite? The main reason I added it is because this instance exists in Haskell as well, but I see your point. I'm not sure this would get a lot of (legitimate) use. Maybe it's better to remove and consider re-adding if we get requests/issues for real use cases.
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.
Would it be possible to use Eq1 m
instead of this constraint, if we keep it?
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.
I removed both Eq
and Ord
for now. It might be possible to use Eq1
though, so I'll keep that in mind if we end up implementing it eventually.
I think I addressed all review comments. Thank you for taking your time to review my PR! |
Description of the change
I'm looking for early feedback.
Here's my attempt at implementing
CofreeT
. I'm not very sure it's correct, so I would love some feedback. I've mostly followed the existingFreeT
code and looked at the HaskellCofreeT
signatures.Fixes #14
I will definitely add documentation, and follow the rest of the checklist as appropriate. I'm currently looking for early feedback on the implementation. If it would make it easier for you to provide feedback on a "complete" PR (i.e. including docs, tests, etc.), I would be happy to oblige.
Checklist: