Announcing Chevrons.jl
I’ve made another package for chaining/piping data transformations together, similar to Chain.jl and Pipe.jl, stealing some of their ideas but with nicer >>
-based syntax and REPL integration.
Here is a little example of using it with TidierData.jl:
julia> using Chevrons, DataFrames, TidierData
julia> Chevrons.enable_repl() # magic to enable Chevrons syntax in the REPL
julia> df = DataFrame(name=["John", "Sally", "Roger"], age=[54, 34, 79], children=[0, 2, 4])
3×3 DataFrame
Row │ name age children
│ String Int64 Int64
─────┼─────────────────────────
1 │ John 54 0
2 │ Sally 34 2
3 │ Roger 79 4
julia> df >> @filter(age > 40) >> @select(num_children=children, age)
2×2 DataFrame
Row │ num_children age
│ Int64 Int64
─────┼─────────────────────
1 │ 0 54
2 │ 4 79
What I particularly like about it:
- Less repetititve: You don’t need to write
@chain
or@pipe
every time, you can annotate an entire function, script or module with@chevrons
to get the>>
syntax. - REPL integration so you can use this syntax automatically.
>>
is easier to type than|>
.- Side-effects with
>>>
, similar to Chain.jl’s@aside
, e.g. for logging intermediate values.
Quick comparison with similar packages:
Feature | Chevrons.jl | Chain.jl | Pipe.jl |
---|---|---|---|
Piping syntax | ![]() >> ) |
![]() @chain ) |
![]() |> ) |
Side effects | ![]() >>> ) |
![]() @aside ) |
![]() |
Pipe backwards | ![]() << ) |
![]() |
![]() |
Recursive syntax | ![]() |
![]() |
![]() |
REPL integration | ![]() |
![]() |
![]() |
Line numbers on errors | ![]() |
![]() |
![]() |