src/Pure/PIDE/document.ML
author wenzelm
Thu, 12 Aug 2010 15:19:11 +0200
changeset 38363 af7f41a8a0a8
parent 38355 8cb265fb12fe
child 38373 e8197eea3cd0
permissions -rw-r--r--
clarified "state" (accumulated data) vs. "exec" (execution that produces data); generic type Document.id (ML) / Document.ID;

(*  Title:      Pure/PIDE/document.ML
    Author:     Makarius

Document as collection of named nodes, each consisting of an editable
list of commands.
*)

signature DOCUMENT =
sig
  type id = int
  type exec_id = id
  type command_id = id
  type version_id = id
  val no_id: id
  val parse_id: string -> id
  val print_id: id -> string
  type edit = string * ((command_id * command_id option) list) option
end;

structure Document: DOCUMENT =
struct

(* unique identifiers *)

type id = int;
type exec_id = id;
type command_id = id;
type version_id = id;

val no_id = 0;

fun parse_id s =
  (case Int.fromString s of
    SOME i => i
  | NONE => raise Fail ("Bad id: " ^ quote s));

val print_id = signed_string_of_int;


(* edits *)

type edit =
  string *  (*node name*)
  ((command_id * command_id option) list) option;  (*NONE: remove, SOME: insert/remove commands*)

end;