-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Functorizing Functors
#27
Conversation
Can you summarize what this PR does? |
There were two main motivations for this PR:
One of the underlying issues with the current implementation is that the "functors" aren't really |
function fcollect(x; cache = [], exclude = v -> false) | ||
x in cache && return cache | ||
if !exclude(x) | ||
push!(cache, x) | ||
foreach(y -> fcollect(y; cache = cache, exclude = exclude), children(x)) | ||
end | ||
return cache | ||
end |
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 is the pre- #25 version of this code fwiw
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.
Oh, this entire directory shouldn't exist. I just haven't removed it from the source tree yet.
In the spirit of not keeping too many Zombie PRs around, this was an interesting experiment but is unlikely to become reality any time soon. In particular, the programming interface is a little too "un-julian". Some of the interesting bits are also already in Functors or Optimisers as separate commits/PRs. |
Since there's been a lot of talk about the current interface and limitations thereof, I thought I'd clean up and post a experimental branch that seeks to straighten out the library and make it more flexible. For those of you who saw me talking about recursion schemes and whatnot, this is what that was for ;)
The tests contain examples from this blog series as well as real-world problems that have come up before in Flux (e.g. FluxML/Flux.jl#1284). I plan on adding some Optimisers.jl-related ones and more as this develops. Obviously everything is very, very breaking, so if the experiment works out we'll have to think about potential migration plans. But until then, feedback and use cases where Functors.jl currently fails (e.g. when a custom walk function is required) are welcome!