Reasonml syntax meaning |

60 views Asked by At

What does this symbol mean in ReasonML |

E.g

type something = 
| SomeFunc()
| AnotherFunc()

I couldnt really find an answer on the ReasonML docs

1

There are 1 answers

0
Nalin Ranjan On BEST ANSWER

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.