3
votes

If I create my own type, for example:

type mynew =
 | Base
 | Co of mynew
 | Io of mynew

How do I access/deconstruct this type with pattern matching? So that, if I have IO(CO(IO(BASE))) I can pass it as a value to a function and access the first part (IO) and the tail (CO(IO(BASE)))?

1

1 Answers

4
votes

You just have to apply pattern matching:

match yourParam with 
    Base -> (**) 
    | Co(t) -> (*Something with t*) 
    | Io(t) -> (*Something with t*)