Debian Codegraph @

plugins/ltac2/tac2extffi.ml

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 Tac2val
12 open Tac2ffi
13 open Tac2types
14
15 module Value = Tac2ffi
16
17 (** Make a representation with a dummy from function *)
18 let make_to_repr f = Tac2ffi.make_repr (fun _ -> assert false) f
19
20 (** More ML representations *)
21
22 let to_qhyp v = match Value.to_block v with
23 | (0, [| i |]) -> AnonHyp (Value.to_int i)
24 | (1, [| id |]) -> NamedHyp (CAst.make (Value.to_ident id))
25 | _ -> assert false
26
27 let qhyp = make_to_repr to_qhyp
28
29 let to_bindings = function
30 | ValInt 0 -> NoBindings
31 | ValBlk (0, [| vl |]) ->
32 ImplicitBindings (Value.to_list Value.to_constr vl)
33 | ValBlk (1, [| vl |]) ->
34 ExplicitBindings ((Value.to_list (fun p -> to_pair to_qhyp Value.to_constr p) vl))
35 | _ -> assert false
36
37 let bindings = make_to_repr to_bindings
38
39 let to_constr_with_bindings v = match Value.to_tuple v with
40 | [| c; bnd |] -> (Value.to_constr c, to_bindings bnd)
41 | _ -> assert false
42
43 let constr_with_bindings = make_to_repr to_constr_with_bindings
44
45 let val_format = Tac2dyn.Val.create "format"
46
47 let format = repr_ext val_format