-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmeta.yml
182 lines (138 loc) · 4.24 KB
/
meta.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
fullname: '`coqffi`'
shortname: coqffi
organization: coq-community
community: true
branch: main
action: true
dune: true
synopsis: Tool for generating Coq FFI bindings to OCaml libraries
description: |-
`coqffi` generates the necessary Coq boilerplate to use OCaml functions in a
Coq development, and configures the Coq extraction mechanism accordingly.
authors:
- name: Thomas Letan
- name: Li-yao Xia
- name: Yann Régis-Gianas
- name: Yannick Zakowski
maintainers:
- name: Thomas Letan
nickname: lthms
opam-file-maintainer: lthms@soap.coffee
opam-file-version: dev
license:
fullname: MIT License
identifier: MIT
supported_coq_versions:
text: 8.12 or later
opam: '{(>= "8.12" & < "8.13~") | (= "dev")}'
supported_ocaml_versions:
text: 4.08 or later
opam: '{>= "4.08" & < "4.12~" }'
tested_coq_opam_versions:
- version: 'dev-ocaml-4.11.1-flambda'
- version: '8.12-ocaml-4.11-flambda'
- version: '8.12-ocaml-4.10-flambda'
dependencies:
- opam:
name: cmdliner
version: '{>= "1.0.4"}'
description: |-
[Cmdliner](http://erratique.ch/software/cmdliner) 1.0.4 or later
- opam:
name: sexplib
version: '{>= "0.14"}'
description: |-
[Sexplib](https://github.com/janestreet/sexplib) 0.14 or later
namespace: CoqFFI
build: |-
## Building and installation instructions
Make sure your OPAM installation points to the official Coq repository
as documented [here](https://github.com/coq/opam-coq-archive), and
then, the following should work:
``` shell
git clone https://github.com/coq-community/coqffi.git
cd coqffi
opam install .
```
Alternatively, you can install `coqffi`’s dependencies (as listed in
the **Meta** section of the README), then build it.
```shell
git clone https://github.com/coq-community/coqffi.git
cd coqffi
./src-prepare.sh
dune build -p coq-coqffi
```
keywords:
- name: foreign function interface
- name: extraction
- name: OCaml
categories:
- name: Miscellaneous/Coq Extensions
documentation: |-
## Example
Suppose the following OCaml header file (`file.mli`) is given:
```ocaml
type fd
val std_out : fd
val fd_equal : fd -> fd -> bool [@@pure]
val openfile : string -> fd
val closefile : fd -> unit
val read_all : fd -> string
val write : fd -> string -> unit
```
`coqffi` then generates the necessary Coq boilerplate to use these
functions in a Coq development:
```coq
(* This file has been generated by coqffi. *)
Set Implicit Arguments.
Unset Strict Implicit.
Set Contextual Implicit.
Generalizable All Variables.
From CoqFFI Require Export Extraction.
From SimpleIO Require Import IO_Monad.
From CoqFFI Require Import Interface.
(** * Types *)
Axiom fd : Type.
Extract Constant fd => "Examples.File.fd".
(** * Pure functions *)
Axiom std_out : fd.
Axiom fd_equal : fd -> fd -> bool.
Extract Constant std_out => "Examples.File.std_out".
Extract Constant fd_equal => "Examples.File.fd_equal".
(** * Impure Primitives *)
(** ** Monad Definition *)
Class MonadFile (m : Type -> Type) : Type :=
{ openfile : string -> m fd
; closefile : fd -> m unit
; read_all : fd -> m string
; write : fd -> string -> m unit
}.
(** ** [IO] Instance *)
Axiom io_openfile : string -> IO fd.
Axiom io_closefile : fd -> IO unit.
Axiom io_read_all : fd -> IO string.
Axiom io_write : fd -> string -> IO unit.
Extract Constant io_openfile
=> "(fun x0 k__ -> k__ (Examples.File.openfile x0))".
Extract Constant io_closefile
=> "(fun x0 k__ -> k__ (Examples.File.closefile x0))".
Extract Constant io_read_all
=> "(fun x0 k__ -> k__ (Examples.File.read_all x0))".
Extract Constant io_write
=> "(fun x0 x1 k__ -> k__ (Examples.File.write x0 x1))".
Instance IO_MonadFile : MonadFile IO :=
{ openfile := io_openfile
; closefile := io_closefile
; read_all := io_read_all
; write := io_write
}.
(* The generated file ends here. *)
```
The generated module may introduce additional dependency to your
project. For instance, the `simple-io` feature (enabled by default)
generates the necessary boilerplate to use the impure primitives of
the input module within the `IO` monad introduced by the
`coq-simple-io` package.
See the `coqffi` man pages for more information on how to use it.
---