@@ -93,18 +93,18 @@ defmodule BindExample do
93
93
v + 1
94
94
end
95
95
96
- def only_last_pipe_tagged_result do
97
- 2 |> inc |> bind(inc)
96
+ def only_last_pipe_tagged_result(v) do
97
+ v |> inc |> bind(inc)
98
98
end
99
99
100
- def result_fully_tagged do
101
- 2 |> bind(inc) >>> bind(inc) >>> bind(inc)
100
+ def result_fully_tagged(v) do
101
+ v |> bind(inc) >>> bind(inc) >>> bind(inc)
102
102
end
103
103
end
104
- iex> BindExample.only_last_pipe_tagged_result
104
+ iex> BindExample.only_last_pipe_tagged_result(2)
105
105
{:ok, 4}
106
106
107
- iex> BindExample.result_fully_tagged
107
+ iex> BindExample.result_fully_tagged(2)
108
108
{:ok, 5}
109
109
```
110
110
@@ -130,12 +130,12 @@ defmodule TryCatchExample do
130
130
1 |> tagged_inc >>> tagged_inc >>> tagged_inc
131
131
end
132
132
133
- def raising_result_wrapped do
134
- 1 |> tagged_inc >>> tagged_inc >>> try_catch(raising_fn) >>> tagged_inc
133
+ def raising_result_wrapped(v) do
134
+ v |> tagged_inc >>> tagged_inc >>> try_catch(raising_fn) >>> tagged_inc
135
135
end
136
136
end
137
137
138
- iex> TryCatchExample.raising_result_wrapped
138
+ iex> TryCatchExample.raising_result_wrapped(1)
139
139
inc for 1
140
140
inc for 2
141
141
{:error, %RuntimeError{message: " I ' m raising!"}}
@@ -157,13 +157,14 @@ defmodule TeeExample do
157
157
{:ok, v + 1}
158
158
end
159
159
160
- def result do
161
- 1 |> tee(tagged_inc) >>> tee(tagged_inc) >>> tee(tagged_inc)
160
+ def calc(v) do
161
+ v |> tee(tagged_inc) >>> tee(tagged_inc) >>> tee(tagged_inc)
162
162
end
163
163
end
164
164
165
- ## notice how the incremented value is not passed through the pipeline, but just the original argument `1`
166
- iex> TeeExample.result
165
+ ## notice how the incremented value is not passed through the pipeline,
166
+ ## but just the original argument `1`
167
+ iex> TeeExample.calc(1)
167
168
inc for 1
168
169
inc for 1
169
170
inc for 1
0 commit comments