Hi, 

I would like yo know your opinion about cunstructs like this one. I guess 
this is not a priority for Elixir, and I know I can add it to Hex.pm. I'm 
just unhappy with the `with` block and I want to know what you think.

I made a simple implementation here : https://github.com/niahoo/ctrl with 
detailed information of the annotation feature.

Basically it's a `with` block but with standard block syntax and match 
selection with tags :


ctrl do
  {:ok, state} <- init()                              # Classic `with` 
clause
  %{id: id, opts: opts} = state                       # Any expression
  :ok <- register(id)
  :f_repo | {:ok, repo} <- Keyword.fetch(opts, :repo) # Tagged match
  :f_user | {:ok, user} <- Keyword.fetch(opts, :user) # Different tagged 
match
  {:ok, do_something(id, repo, user)}
else
  {:error, _} = err -> err                            # Errors with info
  :f_repo | :error -> {:error, :no_repo_option}       # Errors on :repo only
  :f_user | :error -> {:error, :user_not_set}         # Errors on :user only
end



Thanks for reading :)

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/973acf3d-c0c6-4f01-a8a9-2bf73efd4d85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to