Debian Codegraph @

theories/Corelib/extraction/ExtrOcamlBasic.v

raw
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 Require Corelib.extraction.Extraction.
12
13 (** Extraction to Ocaml : use of basic Ocaml types *)
14
15 Extract Inductive bool => bool [ true false ].
16 Extract Inductive option => option [ Some None ].
17 Extract Inductive unit => unit [ "()" ].
18 Extract Inductive list => list [ "[]" "( :: )" ].
19 Extract Inductive prod => "( * )" [ "" ].
20
21 (** NB: The "" above is a hack, but produce nicer code than "(,)" *)
22
23 (** Mapping sumbool to bool and sumor to option is not always nicer,
24 but it helps when realizing stuff like [lt_eq_lt_dec] *)
25
26 Extract Inductive sumbool => bool [ true false ].
27 Extract Inductive sumor => option [ Some None ].
28
29 (** Restore laziness of andb, orb.
30 NB: without these Extract Constant, andb/orb would be inlined
31 by extraction in order to have laziness, producing inelegant
32 (if ... then ... else false) and (if ... then true else ...).
33 *)
34
35 Extract Inlined Constant andb => "(&&)".
36 Extract Inlined Constant orb => "(||)".
37
38 (* for the dependent principle of equality*)
39 Extract Inlined Constant eq_rew_r_dep => "(fun _ _ t -> t)".