# In Pipe.@pipe, |\> followed by .|\> Gives an error

**URL:** <https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174>\
**Category:** General Usage\
**Tags:** piping\
**Created:** [September 24, 2020, 3:49am UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174 "2020-09-24T03:49:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [September 24, 2020, 3:49am UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174/1 "2020-09-24T03:49:21Z")

</div>

|\> followed by .|\> Gives an error

```julia
@pipe 2 |> _ .+ (1:3) #Works
@pipe 2 .+ (1:3) .|> _^2 #Works
@pipe 2 |> _ .+ (1:3) .|> _^2 #Gives Error

```

Is there a way around this?  
It works the other way round: .|\> followed by |\>  
Example

```julia
@pipe (1:3) .|> _^2 |> sum #Works

```

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [September 24, 2020, 5:22am UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174/2 "2020-09-24T05:22:45Z")

</div>

```julia
using MacroTools
MacroTools.prettify(@macroexpand @pipe 2 |> _ .+ (1:3) .|> _^2 )

```

gives

```julia
:((2 |> 2 .+ (1:3)) .|> (mosquito->mosquito ^ 2))

```

but this works

```julia
@pipe 2 |> _ .+ (1:3) |> _ .^ 2 

```

I think it’s just a parseing bug in Pipe.jl, so should raise an issue on github.

---

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [September 25, 2020, 10:22am UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174/3 "2020-09-25T10:22:08Z")

</div>

Many thanks xiaodai 🙂

---

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [December 3, 2020, 4:02am UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174/4 "2020-12-03T04:02:42Z")

</div>

this is still giving an error. I haven’t raised an issue before. can you send a link to the place

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [December 3, 2020, 4:48am UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174/5 "2020-12-03T04:48:56Z")

</div>

> [@Lincoln\_Hannah](#):
>
> can you send a link to the place

> **[Issues · oxinabox/Pipe.jl](https://github.com/oxinabox/Pipe.jl/issues)**
>
> An enhancement to julia piping syntax. Contribute to oxinabox/Pipe.jl development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [January 8, 2025, 8:04pm UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174/6 "2025-01-08T20:04:10Z")

</div>

You can try @chain : [GitHub - jkrumbiegel/Chain.jl: A Julia package for piping a value through a series of transformation expressions using a more convenient syntax than Julia's native piping functionality.](https://github.com/jkrumbiegel/Chain.jl)

```julia
julia> @chain 2 _ .+ (1:3) map(_) do x x^2 end
3-element Vector{Int64}:
  9
 16
 25

```

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [January 8, 2025, 9:04pm UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174/7 "2025-01-08T21:04:09Z")

</div>

This thread is from 4.5 years ago, the landscape was quite different back then 🙂  
With [DataPipes.jl](https://discourse.julialang.org/t/ann-datapipes-jl-0-3-0/60734), one can write the original example from the first post basically without any changes, and continue using `.|>`:

```julia
julia> @p 2 |> __.+ (1:3) .|>__^2
3-element Vector{Int64}:
  9
 16
 25

```

> **or use \`map\` as you suggest**
>
> ```julia
> julia> @p 2 |> __.+ (1:3) |> map(_^2)
> 3-element Vector{Int64}:
> 9
> 16
> 25
> 
> ```

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [January 8, 2025, 10:18pm UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174/8 "2025-01-08T22:18:57Z")

</div>

Nice!

And how do I do this?

```julia
julia> Pipe.@pipe """[{"a":1},{"a":2},{"a":3}]""" |> JSON.parse .|> _["a"]
3-element Vector{Int64}:
 1
 2
 3

julia> DataPipes.@pipe """[{"a":1},{"a":2},{"a":3}]""" |> JSON.parse .|> _["a"]
ERROR: syntax: all-underscore identifier used as rvalue around /home/hugo/.julia/packages/DataPipes/emgTy/src/pipe.jl:211

```

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [January 8, 2025, 11:34pm UTC](https://discourse.julialang.org/t/in-pipe-pipe-followed-by-gives-an-error/47174/9 "2025-01-08T23:34:35Z")

</div>

That’s

```julia
@p """[{"a":1},{"a":2},{"a":3}]""" |> JSON.parse .|> __["a"]

```

In DataPipes.jl, `_` refers to the anonymous function argument, like `@p 1:3 |> map(_ + 1)`. Use `__` to refer to the previous step of the pipeline.
