Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Question] Do you have FromTaggetStatus in Exceptional? #29

Open
Fl4m3Ph03n1x opened this issue Jul 6, 2020 · 0 comments
Open

[Question] Do you have FromTaggetStatus in Exceptional? #29

Fl4m3Ph03n1x opened this issue Jul 6, 2020 · 0 comments

Comments

@Fl4m3Ph03n1x
Copy link

Fl4m3Ph03n1x commented Jul 6, 2020

Background

I have been reading about Exceptional and I have already read the Medium blog post as well as the docs.
Namely, one thing jumped to my attention:

Exceptional.TaggedStatus
View Source

Convert back to conventional Erlang/Elixir {:ok, _} tuples

You seem to have the functionality "ToTaggetStatus", but I was unable to find anything to convert from it.

Example

Consider the following code:

#A bad JSON string we cannot decode into elixir
iex> bad_order_str = "{\"a\": 1, b: 2}"
"{\"a\": 1, b: 2}"

#A good JSON string we can decode into elixir
iex> good_order_str = "{\"a\": 1, \"b\": 2}"
"{\"a\": 1, \"b\": 2}"

#standard JSON encoder/decoder
iex> Jason.decode(bad_order_str)
# KABOOM

iex> Jason.decode(good_order_str) ~> IO.inspect 
{:ok, %{"a" => 1, "b" => 2}}

Lets say I want to use JASON to encode and decode data. I am pretty much forced to use the bang (!) notation because Jason will give me a tagged tuple otherwise, thus defeating one of the main selling points of Exceptional (no more bangs!).

Alternatively, I have to make all my functions that pipe from functions returning tagged tuples to be able to cope with tagged tuples, which then forces me to use them throughout the rest of the code, which again defeats the purpose of using this library.

Questions

So, with this in mind, I am rather confused on how to proper use this library and if it fits my use case at all (involves a lot of JSON and side effects).

  • how do you handle tagged tuples in your code?
  • why don't you have a "FromTaggedStatus" module? (Is it because of the inconsistencies explained in your article?)
  • am I missing the true purpose/power of the library?
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant