I'm new to OCaml and I have no clue why this is giving 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 it's saying is that there's a syntax error on line 14 characters 0-1 (which is where | Sequence of list
is) and I can't figure out why!
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 define product types, as in 'a * 'b
. Although probably not too important now, you should know that Node of 'a * 'b
and Node of ('a * 'b)
are different. You can think of them as a variant type with two parameters, and the other a variant type with one parameter (a tuple), respectively.
There are a few other things,
Sequence
and Repeat
are a list of. 'nonterminal
and 'terminal
aren't used; unless they are for phantom types, which i doubt it, they probably should be used in part of the signature.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With