Debian Codegraph @

plugins/ltac2/tac2val.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open Names
12
13 (** {5 Toplevel values} *)
14
15 (** {5 Dynamic semantics} *)
16
17 (** Values are represented in a way similar to OCaml, i.e. they contrast
18 immediate integers (integers, constructors without arguments) and structured
19 blocks (tuples, arrays, constructors with arguments), as well as a few other
20 base cases, namely closures, strings, named constructors, and dynamic type
21 coming from the Rocq implementation. *)
22
23 type tag = int
24
25 type closure
26
27 type valexpr =
28 | ValInt of int
29 (** Immediate integers *)
30 | ValBlk of tag * valexpr array
31 (** Structured blocks *)
32 | ValStr of Bytes.t
33 (** Strings *)
34 | ValCls of closure
35 (** Closures *)
36 | ValOpn of KerName.t * valexpr array
37 (** Open constructors *)
38 | ValExt : 'a Tac2dyn.Val.tag * 'a -> valexpr
39 (** Arbitrary data *)
40
41 module Valexpr :
42 sig
43 type t = valexpr
44 val is_int : t -> bool
45 val tag : t -> int
46 val field : t -> int -> t
47 val set_field : t -> int -> t -> unit
48 val make_block : int -> t array -> t
49 val make_int : int -> t
50 end
51
52 (** Closures *)
53
54 type 'a arity
55
56 val arity_one : (valexpr -> valexpr Proofview.tactic) arity
57 val arity_suc : 'a arity -> (valexpr -> 'a) arity
58
59 val mk_closure : 'v arity -> 'v -> closure
60 (** The arrows in ['v] should be pure. Use [tclLIFT] or do
61 [tclUNIT () >>= fun () -> f args] when you need effects. *)
62
63 val mk_closure_val : 'v arity -> 'v -> valexpr
64 (** Composition of [mk_closure] and [ValCls] *)
65
66 val annotate_closure : Tac2expr.frame -> closure -> closure
67 (** The closure must not be already annotated *)
68
69 val purify_closure : 'v arity -> 'v -> 'v
70 (** For internal use (Tac2externals). Wraps the applications of the ['v] argument
71 to make it pure. *)
72
73 val to_closure : valexpr -> closure
74
75 val apply : closure -> valexpr list -> valexpr Proofview.tactic
76 (** Given a closure, apply it to some arguments. Handling of argument mismatches
77 is done automatically, i.e. in case of over or under-application. *)
78
79 val apply_val : valexpr -> valexpr list -> valexpr Proofview.tactic
80 (** Composition of [to_closure] and [apply] *)
81
82 val abstract : int -> (valexpr list -> valexpr Proofview.tactic) -> closure
83 (** Turn a fixed-arity function into a closure. The inner function is guaranteed
84 to be applied to a list whose size is the integer argument. *)