4

The code below will report Syntax error message:

type 'a edge = 
  |Empty 
  |End of 'a * 'a vertex * 'a vertex and
type 'a vertex = 
  |Empty
  |Vertex of 'a * 'a edge list;;

How to define two types referring to each other?

nlucaroni
  • 47,556
  • 6
  • 64
  • 86
lkahtz
  • 4,706
  • 8
  • 46
  • 72

1 Answers1

8

The second type is not syntactically correct:

type 'a edge = 
  |Empty 
  |End of 'a * 'a vertex * 'a vertex
and 'a vertex = 
  |Empty
  |Vertex of 'a * 'a edge list;;
Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151