3

I am trying to write some game on tezos via ReasonML, stuck with pattern matching on tuples, looks like it does not work

let tmp =
    switch (players) {
    | (Some(p), None) =>
      let storage = storage.playerO = Some(Current.source());

      ([], storage);
    | (None, Some(_)) =>
      let storage = storage.playerX = Some(Current.source());

      ([], storage);
    | (_, _) => failwith("No empty slots")
    };

I'm getting "Bad pattern" compile error. But it seems like valid Reason syntax.

1
  • 1
    Hi! Welcome to Tezos Stack Exchange. Could you please provide the exact error message you get ? thank you.
    – Ezy
    Mar 13, 2019 at 12:13

1 Answer 1

4

Indeed, Liquidity does not implement deep pattern-matching as in OCaml or Reason. You have to match only one level (constructor or tuple) at a time. We hope to be able to improve that in later versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.