OCaml syntax error in type declaration

I'm new to OCaml and I don't know why this gives me a syntax error:

type ('nonterminal, 'terminal) pe =
| Empty
| T of t 
| N of n
| Seq of list
| Choose of list
| Star of e
| Not of e;;

type ('nonterminal, 'terminal) pe_tree = 
| Is_empty 
| Leaf of t 
| Node of (n,tree) 
| Sequence of list 
| Repeat of list 
| Is_not of e;;

All he says is a syntax error in lines of 14 characters 0-1 (where it is | Sequence of list), and I canโ€™t understand why!

+5
source share
1 answer
type ('nonterminal, 'terminal) pe_tree = 
  | Is_empty 
  | Leaf of t 
  | Node of (n * tree) 
  | Sequence of list 
  | Repeat of list 
  | Is_not of e;;

You use *to determine the types of products, as in 'a * 'b. Although this is probably not so important right now, you should know that Node of 'a * 'bthey Node of ('a * 'b)are different. You can think of them as a variant type with two parameters, and the other on a variant type with one parameter (tuple), respectively.

There are a few more things

  • you need to determine what Sequenceu Repeatare a list.
  • 'nonterminal 'terminal ; phantom, , , , , .
+8

All Articles