StrawHat v0.6.0 StrawHat View Source

Utility package used on Straw Hat Ecosystem.

Link to this section Summary

Functions

A returns the parameter back.

Pipes the subject through the given anonymous function and returns function's result. This function is useful to pipe the subject through an anonymous function, without having to do 1 |> (&to_string/1).(), which is a little bit to much parens.

Pipes the subject through the given anonymous function but always returns subject. This function might be useful in situations you want to transform the subject in something else and print it, or to save it to a file. Basically anything which may generate some side effects but you don't care about the results.

Link to this section Functions

A returns the parameter back.

Examples

iex> StrawHat.identity(1)
1
Link to this function

pipe(subject, function)

View Source
pipe(any(), (any() -> any())) :: any()

Pipes the subject through the given anonymous function and returns function's result. This function is useful to pipe the subject through an anonymous function, without having to do 1 |> (&to_string/1).(), which is a little bit to much parens.

Examples

iex> 1 |> StrawHat.pipe(&to_string/1)
"1"
Link to this function

tap(subject, function)

View Source
tap(any(), (any() -> any())) :: any()

Pipes the subject through the given anonymous function but always returns subject. This function might be useful in situations you want to transform the subject in something else and print it, or to save it to a file. Basically anything which may generate some side effects but you don't care about the results.

Examples

iex> 1 |> StrawHat.tap(&to_string/1) |> Kernel.+(1)
2