Skip to content

Commit c8f84be

Browse files
committed
some improvements for examples
1 parent 9a8b815 commit c8f84be

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,18 @@ defmodule BindExample do
9393
v + 1
9494
end
9595
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)
9898
end
9999
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)
102102
end
103103
end
104-
iex> BindExample.only_last_pipe_tagged_result
104+
iex> BindExample.only_last_pipe_tagged_result(2)
105105
{:ok, 4}
106106
107-
iex> BindExample.result_fully_tagged
107+
iex> BindExample.result_fully_tagged(2)
108108
{:ok, 5}
109109
```
110110
@@ -130,12 +130,12 @@ defmodule TryCatchExample do
130130
1 |> tagged_inc >>> tagged_inc >>> tagged_inc
131131
end
132132
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
135135
end
136136
end
137137
138-
iex> TryCatchExample.raising_result_wrapped
138+
iex> TryCatchExample.raising_result_wrapped(1)
139139
inc for 1
140140
inc for 2
141141
{:error, %RuntimeError{message: "I'm raising!"}}
@@ -157,13 +157,14 @@ defmodule TeeExample do
157157
{:ok, v + 1}
158158
end
159159
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)
162162
end
163163
end
164164
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)
167168
inc for 1
168169
inc for 1
169170
inc for 1

0 commit comments

Comments
 (0)