-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Docs for Func and AppFunc #4378
base: main
Are you sure you want to change the base?
Conversation
I think the doc needs to start with the fact that shape looks almost identical to The issue links to a blog post and explains it and maybe we can just reuse some of the explanation. A very short summary may be that Kleisli is about sequential composition of functions while Func (poorly named) is about parallel compositions of functions. I appreciate your PR, but I think re-explaining other core typeclasses (Applicative, Traverse) shouldn't go in here. |
I was hesitant to mention that. I had written something about it, but though that, given that AppFunc is "more general" than Kleisli it would be confusing to mention Kleisli for someone unfamiliar to it. |
Ok, I mentioned the similarities with Kleisli and removed over explanation of traverse, just left the link to the applicative docs and an example |
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.
docs/datatypes/directory.conf needs to be updated with a reference to this page.
I left some small fixup suggestions as well, but I have to wonder if this article would be more useful if it started by introducing AppFunc directly, then discussing Func as a weaker version after (similar to how Apply is described in the Applicative article). With the current version, the motivation for caring (how to: compose applicative functors), is buried really deep.
docs/datatypes/func.md
Outdated
@@ -0,0 +1,78 @@ | |||
# Func |
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.
A link to the scaladoc should be added now that #4401 is merged.
docs/datatypes/func.md
Outdated
@@ -0,0 +1,78 @@ | |||
# Func |
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.
Since AppFunc
is so important here, maybe the title should be "Func and AppFunc"? Some of the typeclasses are done this way.
docs/datatypes/func.md
Outdated
|
||
# AppFunc | ||
|
||
AppFunc extends Func to wrap around a special type of functor: Applicative functors. |
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.
May as well link to the section for reference.
AppFunc extends Func to wrap around a special type of functor: Applicative functors. | |
AppFunc extends Func to wrap around a special type of functor: [Applicative] functors. |
docs/datatypes/func.md
Outdated
|
||
Signature: `AppFunc[F[_], A, B] extends Func[F, A, B]` | ||
|
||
Now, for the reader familiar with `Kleisli`, we find an even more similar data type. `AppFunc` provides compositions of weaker constraint, allowing to compose `AppFunc[F[_], A, B]` with `AppFunc[G[_], C, 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.
I don't think these Kleisli call outs are going to help people trying to figure out what AppFunc is for. Have you considered having a comparison to Kleisli section at the end of the article?
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.
Hey, yes actually I think at the beginning it was at the end but a suggestion was to move it to the beginning. Given that most doubts in the PR introducing the code were around "why do we need this if Kleisli is a thing"
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.
Ha, I guess that's down to a matter of audience. For cats newcomers, Kleisli is probably at least as foreign as this.
Co-authored-by: Justin Reardon <[email protected]>
Co-authored-by: Justin Reardon <[email protected]>
Co-authored-by: Justin Reardon <[email protected]>
Co-authored-by: Justin Reardon <[email protected]>
Co-authored-by: Justin Reardon <[email protected]>
Hey, I saw your suggestions and applied almost all, only question the one about Kleisli, let me know what you think. |
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.
Now that I've read it, the new Kleisli text gives enough context to not feel out of place at the start.
|
||
Func is a wrapper around a `run` function `A => F[B]` where `F` is a functor. Given that, the Func data type is equipped with the known `map` function, and a `mapK` function to apply natural transformations (from a `Func[F[_], A, B]` get an `Func[G[_], A, B]`). | ||
|
||
The signature `Func[F[_], A, B]` is very similar to the signature for [Kleisli](../datatypes/kleisli.md): `Kleisli[F[_], -A, B]`. The difference is that `Func` is a less restrictive data type that wraps around functors, and only provides basic methods `run`, `map`, and `mapK`, while `Kleisli` is strong enough to provide composition, flatMap, and more. We will see a more useful data type just next with `AppFunc`. |
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.
Does just [Kleisli]
without an explicit link not work?
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.
Nope, I got an exception when running the preview. I got this explicit from another doc doing the same, must be for the same reason. Idk why it says the Klesli reference is "ambiguous"
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.
Wierd. Too bad. Maybe 2 sections called "Kleisli" somewhere?
Hi! This pr closes issue 2650.
I tried to keep it simple, since most of the concepts are explained in the Applicative page.
I added some comments whilst I was trying to understand the code. Let me know if anything is wrong, I'm not an expert, so perhaps I got something mixed up.