adapton.ocaml
adapton.ocaml copied to clipboard
Class with Art of itself
This is probably more of an OCaml question than an Adapton question.
How do I create a class that has a field children : Art<List<self>>
?
The MakeArt.Of
indirectly requires a class definition, but the class definition should use the result of MakeArt.Of
itself.
class node =
fun () ->
let object_name = Name.gensym () in
(*let field_name a = (Name.pair object_name (Name.of_string a)) in
let children = ANodeList.cell (field_name "children") [] in*)
object
val id = object_name
(*val children = children*)
method id = id
(*method set_children a = ANodeList.set children a
method children = ANodeList.force children*)
end;;
module Node =
struct
type t = submission
let hash = Hashtbl.seeded_hash
let sanitize x = x
let compare a b = (compare a#id b#id)
let show a = "<node>"
let pp fmt s = Format.fprintf fmt "%s" (show s)
let equal a b = (a#id = b#id)
end;;
module ANodeList = MakeArt.Of(Name)(Types.List (Node));;