--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/30614530-7e33-4cb8-bffb-63c18248d340%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Tom, thanks for the proposal.As OvermindDL1 already hinted, this can lead to a slippery slope where we need to add bang variants, question mark variants, ok/1/2/3/4 to deal with arities and so on. I would suggest building this vocabulary as necessary in your applications or, if you want to share it with the world, it could be a nice library. Hint: the package ok_error seems to be available. :)José ValimSkype: jv.ptecFounder and Director of R&D
On Tue, Apr 16, 2019 at 11:12 PM OvermindDL1 <overm...@gmail.com> wrote:
On Tuesday, April 16, 2019 at 3:04:13 PM UTC-6, t...@scalpel.com wrote:--It is often the case that you want to wrap the result of an operation in an ":ok" or ":error" Tuple. We should add convenience wrapper functions since this is so common and it cleans up otherwise ugly code.def ok(value), do: {:ok, value}def error(value), do: {:error, value}This could be quite useful! On the other side it would be useful to add functions like these as well:def ok!({:ok, value}), do: valuedef ok?({:ok, _value}), do: truedef ok?(_), do: falseAnd so forth for error as well. They are not really useful on their own because matching is better, but for use in pipes that would be quite useful (right now I use the exceptional library, which does similar things and more).
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/0314757d-eff2-4b23-8130-a19ee921b254%40googlegroups.com.
Elixir already has a perfectly fine syntax via curly brackets for creating ok and error tuples, that also works on matching, so my recommendation is still to build an extra vocabulary in your app or as a separate library.
value |> (&{&1}).() |> Tuple.insert_at(0, :ok)
To view this discussion on the web visit https://groups.google.com/d/ msgid/elixir-lang-core/ 0314757d-eff2-4b23-8130- a19ee921b254%40googlegroups. com .
For more options, visit https://groups.google.com/d/ optout .
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2e7204c7-6d06-49f9-8edc-7c631f75063a%40googlegroups.com .
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2e7204c7-6d06-49f9-8edc-7c631f75063a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
value |> (&{:ok, &1}).()
value |> Tuple.wrap() |> Tuple.insert_at(0, :ok)
{:ok, value}
value|> very()|> long()|> pipeline()|> Tuple.wrap()|> Tuple.insert_at(0, :ok)
value|> very()|> long()|> pipeline()|> OkError.ok()
var =value|> very()|> long()|> pipeline()
{:ok, var}
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/721abcf1-0cfd-4824-b54a-ff2aa22487f3%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/5607dc54-2c5d-452c-a5a5-fa6ec03864c3%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/50776062-e75d-4f31-8266-2b633e78bf89%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/f1c5a753-6964-466b-aabb-5f8cdb7c7ec0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.