utahplt / chorex

Choreographic programming in Elixir
https://hex.pm/packages/chorex
MIT License
14 stars 0 forks source link

errors in return expressions #12

Open bennn opened 2 weeks ago

bennn commented 2 weeks ago

The syntax for return expressions is very limited. Below are two tiny examples.

Issue #8 has a bigger example where the choreography ends with an if/else. It wants to return a value in one branch (fine) and loop in the other branch (error).

  defmodule TestChor do
    defchor [Buyer, Seller] do
      Buyer.get_book_title() ~> Seller.(b)
      Seller.get_price("book:" <> b) ~> Buyer.(p)
      0 # ** (Chorex.ProjectionError) Unrecognized code: 0
    end
  end
  defmodule TestChor do
    def double(n), do: n + n

    defchor [Buyer, Seller] do
      Buyer.get_book_title() ~> Seller.(b)
      Seller.get_price("book:" <> b) ~> Buyer.(p)
      double(3) # ** (MatchError) no match of right hand side value: 3
    end
  end