Elixir already has this - "with". https://www.openmymind.net/Elixirs-With-Statement/ E.g.: with true
I don't think that this is `with` (which is really a series of nested `case` statements with exactly two paths per case). case is_email_address?(email) do true -> case String.length(code) == 6 do true -> case EmailConfirmations.get_email_confirmation(email) do %EmailConfirmation{} -> case EmailAddresses.get_email_address(email) do nil -> case Users.create_user(data) do {:ok, user} -> case EmailAddresses.create_email_…
In ML you can't write something like this:
if e is
...
Lit(value)
and Map.find_opt(value) is Some(result)
then Some(result)
...
where the `...` may include many cases and may contain other Lit cases, so that you would need to refactor the whole expression.Haskell's pattern guards can do this, but they can't "split" control-flow in the middle of a case, as in:
Lit(value)
and Map.find_opt(value) is Some(result)
and computation(result) is
Left(a) then ...
Right(b) then ...
but these all fall out completely naturally in the UCS.Also, exhaustiveness Just Works without the need of any type annotation. The system is actually type system agnostic.