open list (* This type definition is accepted, but is interpreted as a description of a tree! ... *) data mutable node a = Node { content : a; visited : bool; neighbors: list (node a) } data mutable graph a = Graph { roots : list (node a) } (* This wonderful definition of depth-first search is accepted, but is really a tree traversal! ... *) val dfs [a, p : perm] ( g: graph a, f: (a | p) -> () | p) : () = let rec visit (n: node a | p) : () = if not n.visited then begin n.visited <- true; f n.content; iter (n.neighbors, visit) end in iter (g.roots, visit) (* An attempt to construct a cyclic graph. *) val g : graph int = let n = Node { content = 0; visited = false; neighbors = (); } in let ns = Cons { head = n; tail = Nil } in n.neighbors <- ns; (* So far, so good! We have a cycle in the heap. *) Graph { roots = ns } (* ... but the type system does not allow us to claim that this thing has type [graph int]. *) (* Local Variables: compile-command: "mezzo graph-naive.mz" End: *)