aboutsummaryrefslogtreecommitdiff
path: root/src/scTypes.mli
diff options
context:
space:
mode:
Diffstat (limited to 'src/scTypes.mli')
-rwxr-xr-xsrc/scTypes.mli190
1 files changed, 113 insertions, 77 deletions
diff --git a/src/scTypes.mli b/src/scTypes.mli
index 46b48c6..f7bcc1b 100755
--- a/src/scTypes.mli
+++ b/src/scTypes.mli
@@ -1,123 +1,159 @@
(** All the types used in the spreadsheet. *)
-exception Error
+(** This module describe the most basic type use in the spreadsheet : every content is,
-type cell = (int * int) * (bool * bool)
+- either a ['a t]
+- either an expression which result to one ['a t]
-type ident = UTF8.t
+*)
+module Type : sig
-type 'a dataFormat =
- | Date: DataType.Num.t dataFormat (* A date in julian day *)
- | Number: DataType.Num.t dataFormat (* Number *)
- | String: DataType.String.t dataFormat (* String *)
- | Bool: DataType.Bool.t dataFormat (* Boolean *)
+ type 'a t
-type numericType =
- | Date
- | Number
+ (** Create a new number *)
+ val number: DataType.Num.t -> DataType.Num.t t
-val get_numeric_type: DataType.Num.t dataFormat -> numericType
+ (** Create a new string *)
+ val string: DataType.String.t -> DataType.String.t t
-type 'a types = private
- | Num : DataType.Num.t dataFormat * DataType.Num.t -> DataType.Num.t types (** A number *)
- | Str : DataType.String.t -> DataType.String.t types (** A string *)
- | Bool : DataType.Bool.t -> DataType.Bool.t types (** A boolean *)
+ (** Create a new boolean *)
+ val boolean: DataType.Bool.t -> DataType.Bool.t t
-val number: DataType.Num.t -> DataType.Num.t types
-val string: DataType.String.t -> DataType.String.t types
-val boolean: DataType.Bool.t -> DataType.Bool.t types
-val date: DataType.Num.t -> DataType.Num.t types
+ (** Create a new date *)
+ val date: DataType.Num.t -> DataType.Num.t t
-(** Private type for an internal representation of return format *)
-type 'a returnType
+ val (=) : 'a t -> 'b t -> bool
-(** Numeric (any format) *)
-val f_num: DataType.Num.t returnType
+ (** Evaluate a type and get the result *)
+ module Eval(T:Sym_type.SYM_TYPE): sig
-(** Date *)
-val f_date: DataType.Num.t returnType
+ val eval: 'a t -> 'a T.obs
-(** Number *)
-val f_number: DataType.Num.t returnType
+ end
-(** Boolean result *)
-val f_bool: DataType.Bool.t returnType
+end
-(** String *)
-val f_string: DataType.String.t returnType
+(** A reference to another cell.
-type refs =
- | Cell of cell (** A cell *)
- | Range of cell * cell (** An area of cells *)
+The reference can be a single cell (ie : A$1) or a range.
-(** This is the cell content *)
-type expression =
- | Value : 'a types -> expression (** A direct value *)
- | Ref : refs -> expression (** A reference to another cell *)
- | Call : ident * expression list -> expression (** A call to a function *)
- | Expression : expression -> expression (** An expression *)
+*)
+module Refs : sig
-(** Result from a computation *)
-type result =
- | Result : 'a types -> result
- | Error : exn -> result
+ type t
-module DataFormat : sig
+ val cell : Cell.t -> t
+
+ val range : Cell.t -> Cell.t -> t
+
+ val shift: (int * int) -> t -> t
- type formats = F : 'a dataFormat -> formats [@@unboxed]
+ (** Evaluate a reference and get the result *)
+ module Eval(R:Sym_ref.SYM_REF): sig
- val guess_format_result: 'a returnType -> (unit -> formats list) -> 'a dataFormat
+ val eval: t -> 'a R.obs
+
+ end
end
-module Type : sig
+module Expr : sig
- type t = Value: 'a dataFormat * 'a -> t
+ type ident = UTF8.t
- val (=) : 'a types -> 'b types -> bool
+ (** This is the cell content *)
+ type t
- val show: UTF8.Buffer.buffer -> 'a types -> unit
+ (** Declare a direct value *)
+ val value: 'a Type.t -> t
- val show_full: UTF8.Buffer.buffer -> 'a types -> unit
+ (** Declare a reference to another cell *)
+ val ref: Refs.t -> t
-end
+ (** Declare a call to a 0 arg function *)
+ val call0: ident -> t
-module Refs : sig
+ (** Declare a call to a 1 arg function *)
+ val call1 : ident -> t -> t
- type 'a range =
- | Single of 'a
- | Array1 of 'a list
- | Array2 of 'a list list
+ (** Declare a call to a 2 arg function *)
+ val call2 : ident -> t -> t -> t
- (* Collect all the cells defined by a range. The cell are defined by their
- coordinates *)
- val collect: refs -> (int * int) range
+ (** Declare a call to a 3 arg function *)
+ val call3 : ident -> t -> t -> t -> t
- val map: ('a -> 'b) -> 'a range -> 'b range
-
- val shift: (int * int) -> refs -> refs
+ (** Declare a call to a function *)
+ val callN : ident -> t list -> t
- (** Each content from a reference contains a format and the appropriate value. *)
- type content =
- | Value: 'a dataFormat * 'a -> content
- | List: 'a dataFormat * 'a list -> content
- | Matrix: 'a dataFormat * 'a list list -> content
+ (** An expression *)
+ val expression : t -> t
- (** extract the content from a range.
+ val shift_exp: (int * int) -> t -> t
- May raise Errors.TypeError if the range cannot be unified.
- *)
- val get_content : result option range -> content
+ module Eval(E:Sym_expr.SYM_EXPR): sig
+
+ val eval: t -> E.t -> E.obs
+
+ end
end
-val show_expr: UTF8.Buffer.buffer -> expression -> unit
+module DataFormat : sig
+
+ type 'a t =
+ | Date: DataType.Num.t t (* A date in julian day *)
+ | Number: DataType.Num.t t (* Number *)
+ | String: DataType.String.t t (* String *)
+ | Bool: DataType.Bool.t t (* Boolean *)
+
+ type formats = F : 'a t -> formats [@@unboxed]
+
+ val default_value_for: 'a t -> 'a
+
+ type ('a, 'b) equality = Eq : ('a, 'a) equality
+
+ val compare_format: 'a t -> 'b t -> ('a, 'b) equality
+
+ val priority: 'a t -> int
+
+end
+
+module ReturnType : sig
+
+ (** Private type for an internal representation of return format *)
+ type 'a t
+
+ (** Numeric (any format) *)
+ val f_num: DataType.Num.t t
+
+ (** Date *)
+ val f_date: DataType.Num.t t
+
+ (** Number *)
+ val f_number: DataType.Num.t t
+
+ (** Boolean result *)
+ val f_bool: DataType.Bool.t t
+
+ (** String *)
+ val f_string: DataType.String.t t
+
+ val guess_format_result: 'a t -> (unit -> DataFormat.formats list) -> 'a DataFormat.t
+
+end
module Result : sig
- val (=) : result -> result -> bool
+ (** Result from a computation *)
+ type t =
+ | Ok : 'a Type.t -> t
+ | Error : exn -> t
- val show: result -> UTF8.t
+ val (=) : t -> t -> bool
+
+ val show: t -> UTF8.t
end
+exception Error
+