-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat transducers as iterator transforms at surface syntax (#319)
This patch implements the idea discussed in #67. That is to say, ```julia collect(Map(f) |> Filter(g), xs) foldl(+, Map(f) |> Filter(g), xs) ``` is now written as ```julia xs |> Map(f) |> Filter(g) |> collect foldl(+, xs |> Map(f) |> Filter(g)) ``` or ```julia collect(opcompose(Map(f), Filter(g)), xs) foldl(+, opcompose(Map(f), Filter(g)), xs) collect(Map(f) ⨟ Filter(g), xs) foldl(+, Map(f) ⨟ Filter(g), xs) ``` or even (not recommended) ```julia collect(Filter(g)((Map(f)(xs)))) # Julia >= 1.3 collect(Filter(g) ∘ Map(f), xs) foldl(+, Filter(g) ∘ Map(f), xs) collect((Filter(g)' ⨟ Map(f)')', xs) foldl(+, (Filter(g)' ⨟ Map(f)')', xs) collect((Map(f)' ∘ Filter(g)')', xs) foldl(+, (Map(f)' ∘ Filter(g)')', xs) ``` Above syntax are all compatible with the view that `xf(itr)` is an iterator transformation. OTOH, `xf'` (`adjoint(::Transducer)`) is now the "classic" transducer; i.e., reducing function transformation. This makes it easy to use transducers with other "reducing function combinators" like `TeeRF`: ```julia rf = TeeRF(Filter(iseven)'(min), Filter(isodd)'(max)) reduce(rf, Map(identity), xs) # => (even minimum, odd maximum) ``` This PR only deprecates `::Transducer |> ::Transducer` to help migration from the old syntax.
- Loading branch information
Showing
59 changed files
with
916 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.