Skip to content

Expand docstrings #30

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

Merged
merged 1 commit into from
Jan 22, 2022
Merged

Expand docstrings #30

merged 1 commit into from
Jan 22, 2022

Conversation

mcabbott
Copy link
Member

This adds more examples to show what this package actually does. Mostly examples, but I fixed the words where I thought them ambiguous, added something about === etc.

Should have no functional changes.

Documenter will run doctests when you do ] test, not only when building docs.

@mcabbott mcabbott force-pushed the docstrings branch 2 times, most recently from 9cfd04f to 6a28efe Compare January 22, 2022 16:55
Comment on lines -107 to -108
By default, traverses `x` recursively using [`functor`](@ref)
and transforms every leaf node identified by `exclude` with `f`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important to know that exclude is used before functor, it stops the recursion, rather than just controlling whether f is applied. I'm not sure that's what we want, but it's what we have.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is deliberate because it's the easiest way to control the depth of recursion. Looking back on #13, I think it might've been better just to call this isleaf: that's literally what it's checking and exclude could imply that f is not being applied to anything the function predicate says is true.

Copy link
Member Author

@mcabbott mcabbott Jan 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Maybe all names for such things are confusing...

What it sounds like it might do is let you tell fmap(sqrt, (2, Foo(3, sin))) which leaves to apply f to, and which to leave alone, without altering recursion. I guess you can test isleaf first. Maybe all functionality can be written in terms of any other...

Copy link
Member

@ToucheSir ToucheSir Jan 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little confusing because f is also used as a name for not the original user callback, but in essence Functors will try to recurse into anything "left alone" by isleaf/exclude. It's just that the fallback definition of functor returns an empty tuple of children, so recursion naturally stops if the value in question can't be unpacked.

@mcabbott mcabbott merged commit 937c8d2 into FluxML:master Jan 22, 2022
@mcabbott mcabbott deleted the docstrings branch January 23, 2022 03:12
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

Successfully merging this pull request may close these issues.

2 participants