reason

Reasonml syntax meaning |


What does this symbol mean in ReasonML |

E.g

type something = 
| SomeFunc()
| AnotherFunc()

I couldnt really find an answer on the ReasonML docs


Solution

  • Essentially, this particular one is a case of defining a custom type.

    We are defining a new type called something, the values of which can be created using either the function SomeFunc or AnotherFunc.. More specifically, these functions are called Constructor Functions... Quite useful with pattern-matching.

    You can read more about them in the OCaml documentation.

    You can also find the pipe symbol (|) inside pattern-matching constructs, separating various cases/variations of match-patterns.