package coq-of-ocaml
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=889046cbfdc479b02aa9a97bcb6284df7539eba60e0f37f03c365e658445395d
    
    
  sha512=eec30792f4ab93a4ce9f8b94880c6e44bd7bc11424e24258c20e06e414af10fc108435543976e9c962ed7bbf17384cfe3bcf9114c90aeb57f3e1e188716537fe
    
    
  doc/README.html
 coq-of-ocaml
 coq-of-ocaml
https://clarus.github.io/coq-of-ocaml/
Start with the file main.ml:
type 'a tree =
  | Leaf of 'a
  | Node of 'a tree * 'a tree
let rec sum tree =
  match tree with
  | Leaf n -> n
  | Node (tree1, tree2) -> sum tree1 + sum tree2Run:
coq-of-ocaml main.mlGet a file Main.v:
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.
Local Set Primitive Projections.
Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Inductive tree (a : Set) : Set :=
| Leaf : a -> tree a
| Node : tree a -> tree a -> tree a.
Arguments Leaf {_}.
Arguments Node {_}.
Fixpoint sum (tree : tree int) : int :=
  match tree with
  | Leaf n => n
  | Node tree1 tree2 => Z.add (sum tree1) (sum tree2)
  end.Features
- core of OCaml (functions, let bindings, pattern-matching,...) ✔️
- type definitions (records, inductive types, synonyms, mutual types) ✔️
- modules as namespaces ✔️
- modules as dependent records (signatures, functors, first-class modules) ✔️
- projects with complex dependencies using .merlinfiles ✔️
- .mland- .mlifiles ✔️
- existential types ✔️
- partial support of GADTs 🌊
- partial support of polymorphic variants 🌊
- ignores extensible types ❌
- ignores side-effects ❌
Even in case of errors we try to generate some Coq code. The generated Coq code should be readable and with a size similar to the OCaml source. One should not hesitate to fix remaining compilation errors, by hand or with a script (name collisions, missing Require,...).
Install
Latest stable version
Using the package manager opam,
opam install coq-of-ocamlCurrent development version
To install the current development version:
opam pin add https://github.com/clarus/coq-of-ocaml.git#masterManually
Read the coq-of-ocaml.opam file at the root of the project to know the dependencies to install and get the list of commands to build the project.
Usage
coq-of-ocaml compiles the .ml or .mli files using Merlin to understand the dependencies of a project. One first needs to have a compiled project with a working configuration of Merlin. The basic command is:
coq-of-ocaml file.mlIf this does not work as expected, you may specify the path to a .merlin file:
coq-of-ocaml -merlin src/.merlin path/file.mlYou can start to experiment with the test files in tests/ or look at our online examples.
License
MIT © Guillaume Claret.