witchcrafters / witchcraft

Monads and other dark magic for Elixir
https://witchcrafters.github.io
MIT License
1.2k stars 58 forks source link

Right and left sparrows #89

Open cognivore opened 3 years ago

cognivore commented 3 years ago

I'd like to write this:

    res = naive_run_receive_loop(Resp.new!(p, []), command, timeout)

    try do
      Port.close(p)
    rescue
      _ -> :ok
    end

    res

as

naive_run_receive_loop(Resp.new!(p, []), command, timeout) <* close(p)

# ...

defp close(p) do
    try do
      Port.close(p)
    rescue
      _ -> :ok
    end
end

But I can't find the necessary operator. Am I missing something or it's currently impossible?

cognivore commented 2 years ago

In case anyone needs a simple abstraction for this stuff and similar stuff, I have it in DynHacks.