This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,53 @@
$ cat >dune-project <<EOF
> (lang dune 2.5)
> (using coq 0.2)
> EOF
$ cat >extract.v <<EOF
> Definition nb (b : bool) : bool :=
> match b with
> | false => true
> | true => false
> end.
>
> Require Extraction.
> Separate Extraction nb.
> EOF
$ cat >dune <<EOF
> (coq.extraction
> (prelude extract)
> (extracted_modules Datatypes extract))
>
> (executable
> (name foo))
> EOF
$ cat >foo.ml <<EOF
> open Datatypes
> let () =
> print_endline (
> match Extract.nb Datatypes.Coq_true with
> | Coq_true -> "true"
> | Coq_false -> "false"
> )
> EOF
$ dune exec ./foo.exe
Warning: Coq Language Versions lower than 0.8 have been deprecated in Dune
3.8 and will be removed in an upcoming Dune version.
Hint: To disable this warning, add the following to your dune-project file:
(warnings (deprecated_coq_lang_lt_08 disabled))
false
$ ls _build/default
Datatypes.ml
Datatypes.mli
extract.glob
extract.ml
extract.mli
extract.v
extract.vo
extract.vok
extract.vos
foo.exe
foo.ml

View file

@ -0,0 +1,14 @@
(executable
(name my_prog))
(rule
(target my_coq_file.ml)
(deps extraction/my_coq_file.ml)
(action
(with-stdout-to %{target}
; here you patch stuff
(cat %{deps}))))
(copy_files extraction/Datatypes.ml)
(copy_files extraction/Datatypes.mli)
(copy_files extraction/my_coq_file.mli)

View file

@ -0,0 +1,2 @@
(lang dune 3.7)
(using coq 0.7)

View file

@ -0,0 +1,4 @@
(coq.extraction
(mode vo)
(prelude my_coq_file)
(extracted_modules Datatypes my_coq_file))

View file

@ -0,0 +1,8 @@
Definition nb (b : bool) : bool :=
match b with
| false => true
| true => false
end.
Require Extraction.
Separate Extraction nb.

View file

@ -0,0 +1,10 @@
let bool_to_string (b : Datatypes.bool) : string =
match b with
| Datatypes.Coq_true -> "true"
| Datatypes.Coq_false -> "false"
let () =
Datatypes.Coq_true
|> My_coq_file.nb
|> bool_to_string
|> Printf.printf "Result: %s\n"

View file

@ -0,0 +1,29 @@
$ dune build
Warning: Coq Language Versions lower than 0.8 have been deprecated in Dune
3.8 and will be removed in an upcoming Dune version.
Hint: To disable this warning, add the following to your dune-project file:
(warnings (deprecated_coq_lang_lt_08 disabled))
$ ls _build/default
Datatypes.ml
Datatypes.mli
extraction
my_coq_file.ml
my_coq_file.mli
my_prog.exe
my_prog.ml
my_prog.mli
$ cat _build/default/Datatypes.ml
type bool =
| Coq_true
| Coq_false
$ dune exec -- ./my_prog.exe
Warning: Coq Language Versions lower than 0.8 have been deprecated in Dune
3.8 and will be removed in an upcoming Dune version.
Hint: To disable this warning, add the following to your dune-project file:
(warnings (deprecated_coq_lang_lt_08 disabled))
Result: false