src/Pure/PIDE/document.ML
author wenzelm
Thu Aug 12 15:19:11 2010 +0200 (2010-08-12 ago)
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;
wenzelm@38150
     1
(*  Title:      Pure/PIDE/document.ML
wenzelm@38150
     2
    Author:     Makarius
wenzelm@38150
     3
wenzelm@38150
     4
Document as collection of named nodes, each consisting of an editable
wenzelm@38150
     5
list of commands.
wenzelm@38150
     6
*)
wenzelm@38150
     7
wenzelm@38150
     8
signature DOCUMENT =
wenzelm@38150
     9
sig
wenzelm@38363
    10
  type id = int
wenzelm@38363
    11
  type exec_id = id
wenzelm@38363
    12
  type command_id = id
wenzelm@38363
    13
  type version_id = id
wenzelm@38363
    14
  val no_id: id
wenzelm@38363
    15
  val parse_id: string -> id
wenzelm@38363
    16
  val print_id: id -> string
wenzelm@38150
    17
  type edit = string * ((command_id * command_id option) list) option
wenzelm@38150
    18
end;
wenzelm@38150
    19
wenzelm@38150
    20
structure Document: DOCUMENT =
wenzelm@38150
    21
struct
wenzelm@38150
    22
wenzelm@38150
    23
(* unique identifiers *)
wenzelm@38150
    24
wenzelm@38363
    25
type id = int;
wenzelm@38363
    26
type exec_id = id;
wenzelm@38363
    27
type command_id = id;
wenzelm@38363
    28
type version_id = id;
wenzelm@38355
    29
wenzelm@38355
    30
val no_id = 0;
wenzelm@38150
    31
wenzelm@38355
    32
fun parse_id s =
wenzelm@38355
    33
  (case Int.fromString s of
wenzelm@38355
    34
    SOME i => i
wenzelm@38355
    35
  | NONE => raise Fail ("Bad id: " ^ quote s));
wenzelm@38355
    36
wenzelm@38355
    37
val print_id = signed_string_of_int;
wenzelm@38150
    38
wenzelm@38150
    39
wenzelm@38150
    40
(* edits *)
wenzelm@38150
    41
wenzelm@38150
    42
type edit =
wenzelm@38150
    43
  string *  (*node name*)
wenzelm@38150
    44
  ((command_id * command_id option) list) option;  (*NONE: remove, SOME: insert/remove commands*)
wenzelm@38150
    45
wenzelm@38150
    46
end;
wenzelm@38150
    47