Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class with Art of itself #32

Open
dcharkes opened this issue Jun 14, 2016 · 0 comments
Open

Class with Art of itself #32

dcharkes opened this issue Jun 14, 2016 · 0 comments

Comments

@dcharkes
Copy link

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));;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant