aboutsummaryrefslogtreecommitdiff
path: root/scTypes.mli
blob: deef1a09cd9ba2bc27387fe931b04fbb35a333cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(** All the types used in the spreadsheet. *)

exception Error

type cell = (int * int) * (bool * bool)

type ident = UTF8.t

type types =
  | Num  of Num.num * (UTF8.t option)     (** A number *)
  | Str  of UTF8.t                        (** A string *)
  | Date of Num.num                       (** A date in julian day *)

  | Undefined                             (** The content is not defined *)
  | Bool of bool                          (** A boolean *)

type refs =
  | Cell of cell                          (** A cell *)
  | Range of cell * cell                  (** An area of cells *)

type expression =
  | Value of types                        (** A direct value *)
  | Ref of refs                           (** A reference to another cell *)
  | Call of ident * expression list       (** A call to a function *)
  | Expression of expression              (** An expression *)

(** Result from a computation *)
type result =
  | Result of types
  | Error of exn

module Type : sig

  val (=) : types -> types -> bool

  val show: UTF8.Buffer.buffer -> types -> unit

end

module Refs : sig

  type 'a range =
    | Single of 'a
    | Array1 of 'a list
    | Array2 of 'a list list

  val collect: refs -> (int * int) range

  val map: ('a -> 'b) -> 'a range -> 'b range
  
  val shift: (int * int) -> refs -> refs

end

val show_expr: UTF8.Buffer.buffer -> expression -> unit

module Result : sig

  val (=) : result -> result -> bool

  val show: result -> UTF8.t

end