[ docs ] Improved documentation for Prelude.Interfaces - #3831
user470750 wants to merge 9 commits into
Conversation
| ||| A functor with application, providing operations to embed | ||
| ||| pure expressions (`pure`) and sequence computations (`<*>`). | ||
| ||| Abstracts the notion of function application. | ||
| ||| @ f a parameterised type |
There was a problem hiding this comment.
IMO the @ fs are unnecessary here, and busy the docs. They're also not reflected by docs for a and b later
There was a problem hiding this comment.
I based my choice of which arguments to document on the existing documentation for Functor.
There was a problem hiding this comment.
ah, well I guess I disagree with Edwin there. But yeah it makes sense to copy Functor's style.
| ||| Sequence actions, discarding the value of the second argument. | ||
| ||| | ||
| ||| ```idris example | ||
| ||| (Just 5 <* Just 10) == Just 5 |
There was a problem hiding this comment.
Note this example doesn't convey that the second effect is used. The converse of the (*>) example might help
Main> Just 2 <* Nothing
Nothing
It's a shame sth like State wouldn't be suitable here.
There was a problem hiding this comment.
Thank you for pointing this out, I'll add such an example.
There was a problem hiding this comment.
Added the second example for <*.
| public export | ||
| interface Functor f => Applicative f where | ||
| constructor MkApplicative | ||
| ||| Lift a value into the structure. |
There was a problem hiding this comment.
Is "structure" always appropriate? What about IO or State? You use Applicative further down, though I don't think that's strictly true either. Is the Applicative not the pure and (<*>), rather than e.g. the Maybe? I'm unsure if Maybe "is an applicative functor" (small "a").
I'm aware that genericity of these interfaces will make it difficult to document them accurately, without it becoming impractically abstract.
There was a problem hiding this comment.
For example, the word "structure" is used in the tutorial for Functor:
Idris2/docs/source/tutorial/interfaces.rst
Lines 238 to 239 in 811e065
As for the wording "Applicative", I'm using it by analogy with the documentation for
Biapplicative though I'm not sure how reliable a source the tests are for documentation wording.It might make sense to use the same wording ("Applicative") for pure as well, for consistency.
In some of the phrasing, I also looked at Haskell for reference (e.g. "functor with application").
Also for example, the documentation for the functions related to Functor (
map, <$>, <&>, etc.) uses the wording "a parameterised type".
Do you have any suggestions for alternative wording instead of "structure" and "Applicative"?
There was a problem hiding this comment.
I would guess the haskell docs would be the standard to follow. And they call it a structure, so seems sensible.
Add second example for `<*`, analogous to the `*>` example with `Nothing` to convey that the second effect is used
Description
Applicativeinterface and thepure,<*>,*>, and<*functions, including code examples. Examples use==in accordance with the documentation style in Prelude.Interfaces.mapHomfunction following the style of the documentation forbimap,mapFst,mapSnddocumentation.TraversableandBitraversableintefaces.Bifoldableinterface following the style of the documentation forFoldable.Self-check