Skip to content
Snippets Groups Projects
stdlib.mli 4.76 KiB
Newer Older
charguer's avatar
charguer committed

(*--------------------*)
charguer's avatar
charguer committed
(* int operations *)
charguer's avatar
charguer committed

(* todo : factorize and clean up *)
charguer's avatar
charguer committed
(*
val ( ~+ ) : int -> int
val ( ~- ) : int -> int
charguer's avatar
charguer committed
*)

Thomas Wood's avatar
Thomas Wood committed
val ( + ) : int -> int -> int
val ( - ) : int -> int -> int
val ( * ) : int -> int -> int
val ( / ) : int -> int -> int

charguer's avatar
charguer committed
(*val int_abs : int -> int*)
Alan Schmitt's avatar
Alan Schmitt committed

charguer's avatar
charguer committed
val nat_eq : int -> int -> bool (* nat_eq x y = int_eq x y  *)
val int_eq : int -> int -> bool
val int_ge : int -> int -> bool
(* val int_lt : int -> int -> bool*)

(*--------------------*)
(* float operations *)
Alan Schmitt's avatar
Alan Schmitt committed

Alan Schmitt's avatar
Alan Schmitt committed
(* Alan: these can be implemented directly, using Number.NaN,
   Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY *)
charguer's avatar
charguer committed
(*
val nan : float
val infinity : float
val neg_infinity : float
charguer's avatar
charguer committed
*)
Alan Schmitt's avatar
Alan Schmitt committed

Alan Schmitt's avatar
Alan Schmitt committed
(* Alan: Do we need these ? If so, they are Number.MAX_VALUE and
charguer's avatar
charguer committed
   Number.MIN_VALUE
Alan Schmitt's avatar
Alan Schmitt committed

val max_float : float
charguer's avatar
charguer committed
val min_float : float
Alan Schmitt's avatar
Alan Schmitt committed

charguer's avatar
charguer committed
 *)


Alan Schmitt's avatar
Alan Schmitt committed
(* Alan: these should all be implemented along with the int operations as the JS
   ones. ** is Math.pow *)

charguer's avatar
charguer committed
(*
val ( ~+. ) : float -> float
val ( ~-. ) : float -> float
charguer's avatar
charguer committed
*)

val ( +. ) : float -> float -> float
val ( -. ) : float -> float -> float
val ( *. ) : float -> float -> float
val ( /. ) : float -> float -> float
charguer's avatar
charguer committed
(* val ( ** ) : float -> float -> float *)
Alan Schmitt's avatar
Alan Schmitt committed


charguer's avatar
charguer committed
(*
val mod_float : float -> float -> float (* Alan: % infix *)
*)
Alan Schmitt's avatar
Alan Schmitt committed

(* Alan: Why do we need these? If need be, they are all in Math *)

charguer's avatar
charguer committed
(*
val atan : float -> float
val exp : float -> float
val log : float -> float
val min : float -> float -> float
val max : float -> float -> float
charguer's avatar
charguer committed
*)
Alan Schmitt's avatar
Alan Schmitt committed

charguer's avatar
charguer committed

Alan Schmitt's avatar
Alan Schmitt committed
(* Alan: Ideally we would add these to the spec, but for the moment conversion
   to a string is doing a foo+"", and conversion to an int is doing +foo *)

charguer's avatar
charguer committed
val int_of_float : float -> int (* will be removed, since only used by substring *)
charguer's avatar
charguer committed
val number_of_int : int -> float  (* = fun x -> float_of_int x *)

(** val of_int : float -> number **)
val of_int : float -> float (* = fun x -> x,  
  that is, an identity function, kept in files for documentation *)


(*val float_of_string : string -> float*)
(*val float_of_int : int -> float*)
(*
val int_of_char : char -> int
val string_of_float : float -> string
val string_of_int : int -> string
charguer's avatar
charguer committed
*)
charguer's avatar
charguer committed

(* no need to implement those in stdlib.js because JS has them already *)
charguer's avatar
charguer committed
val ( = ) : float -> float -> bool
val ( < ) : float -> float -> bool
val ( > ) : float -> float -> bool
val ( <= ) : float -> float -> bool 
val ( >= ) : float -> float -> bool
charguer's avatar
charguer committed
val fmod : float -> float -> float (*  mod_float, implemented as % operator in JS *)
charguer's avatar
charguer committed

charguer's avatar
charguer committed
(** val number_comparable : number coq_Comparable **)
val number_comparable : float -> float -> bool  (* = (fun n1 n2 -> int_eq 0  (float_compare n1 n2)) *)
charguer's avatar
charguer committed
  (* same as (=) *)
charguer's avatar
charguer committed

charguer's avatar
charguer committed
(*val compare : 'a -> 'a -> int*)
(*val float_lt : float -> float -> bool
val float_le : float -> float -> bool*)
(*val float_compare : float -> float -> int*)
(* val float_neg : float -> float  ~-.*)
(* val float_exp : float -> float -> float (* ( ** ) *) *)
charguer's avatar
charguer committed


charguer's avatar
charguer committed
(*--------------------*)
(* bool operations *)
charguer's avatar
charguer committed

charguer's avatar
charguer committed
val bool_eq : bool -> bool -> bool (* should be "===" in  JS *)
charguer's avatar
charguer committed
val ( && ) : bool -> bool -> bool  (* beware of strict vs lazy semantics: todo discuss --> just map to  *)
charguer's avatar
charguer committed
val not : bool -> bool
val ( || ) : bool -> bool -> bool  (* beware of strict vs lazy semantics: todo discuss --> just map to  *)
charguer's avatar
charguer committed

(*--------------------*)
(* string operations *)

(* todo : factorize and clean up *)

charguer's avatar
charguer committed
val string_eq : string -> string -> bool (* === *)
charguer's avatar
charguer committed
val string_compare : string -> string -> float (* actually returns an int *)
charguer's avatar
charguer committed
(*
   val string_concat : string -> string -> string (* + *)
   val (^) : string -> string -> string
*)
charguer's avatar
charguer committed

(* let append s1 s2 = String.append s1 s2 *)
charguer's avatar
charguer committed
val strappend : string -> string -> string  (* + *)
charguer's avatar
charguer committed

(* let strlength s = String.length s *)
charguer's avatar
charguer committed
val strlength : string -> int (* in JS :  function (x) { return x.length; } *)
charguer's avatar
charguer committed

(* let substring n m s = String.sub s n m *)
charguer's avatar
charguer committed
val substring : int -> int -> string -> string  (* function(x) { return x.slice(n, n+m); } *)
 (* only need to implement this when m=1 *)
charguer's avatar
charguer committed

charguer's avatar
charguer committed
(*--------------------*)
(* special operations *)

(* We use this to compare types that are not known by stdlib, like Native_error;
  should be implemented in JS by comparing the objects, to see if they have the same
  "tag" fields (there should be no other fields, except perhaps "type") *)
charguer's avatar
charguer committed
val ( === ) : 'a -> 'a -> bool  (* becomes === in js *)
charguer's avatar
charguer committed

charguer's avatar
charguer committed
(*--------------------*)
(* JSRef specific functions, useful for debugging *)
charguer's avatar
charguer committed

charguer's avatar
charguer committed
(* val print_endline : string -> unit *)

val __LOC__ : string (* todo: will not be needed in the future *)
charguer's avatar
charguer committed

charguer's avatar
charguer committed
(*
charguer's avatar
charguer committed
val prerr_string : string -> unit
val prerr_newline : unit -> unit
val prerr_endline : string -> unit
charguer's avatar
charguer committed
*)

val raise : exn -> 'a   (* bind to  throw "Not_found" *)
(*val stuck : string -> 'a*)


charguer's avatar
charguer committed

charguer's avatar
charguer committed


(*--------------------*)
(* for future use for the global heap

val ref : 'a -> 'a ref
val (:=) : 'a ref -> 'a -> unit
val (!) : 'a ref -> 'a
 *)
charguer's avatar
charguer committed