0

What does this symbol mean in ReasonML |

E.g

type something = 
| SomeFunc()
| AnotherFunc()

I couldnt really find an answer on the ReasonML docs

hnhl
  • 127
  • 8
  • Its meaning changes depending on context. Here it's just a separator, separating the different cases of the variant. – glennsl Aug 05 '21 at 07:02

1 Answers1

1

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.

Michael Johansen
  • 964
  • 6
  • 18
Nalin Ranjan
  • 1,728
  • 2
  • 9
  • 10