diff options
| author | Nickolai Zeldovich | 2015-05-23 12:22:48 -0700 |
|---|---|---|
| committer | Pierre Letouzey | 2015-06-22 14:15:00 +0200 |
| commit | 5089872d20c9e3089676c9267a6394e99cca5121 (patch) | |
| tree | 1e2df6141c807761304e25d3328c7f2ebf2ec5c8 /plugins/extraction/ExtrHaskellZNum.v | |
| parent | 949d027ce8fa94b5c62f938b58c3f85d015b177b (diff) | |
Add efficient extraction of [nat], [Z], and [string] to Haskell
This mirrors the existing extraction libraries for OCaml.
One wart: the extraction for [string] requires that the Haskell code
imports Data.Bits and Data.Char. Coq has no way to add extra import
statements to the extracted code. So we have to rely on the user to
somehow import these libraries (e.g., using the -pgmF ghc option).
See also https://coq.inria.fr/bugs/show_bug.cgi?id=4189
Message to github robot: this commit closes #65
Diffstat (limited to 'plugins/extraction/ExtrHaskellZNum.v')
| -rw-r--r-- | plugins/extraction/ExtrHaskellZNum.v | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/extraction/ExtrHaskellZNum.v b/plugins/extraction/ExtrHaskellZNum.v new file mode 100644 index 0000000000..3f645db9b1 --- /dev/null +++ b/plugins/extraction/ExtrHaskellZNum.v @@ -0,0 +1,19 @@ +(** + * Efficient (but uncertified) extraction of usual [Z] functions + * into equivalent versions in Haskell's Prelude that are defined + * for any [Num] typeclass instances. Useful in combination with + * [Extract Inductive Z] that maps [Z] onto a Haskell type that + * implements [Num]. + *) + +Require Import ZArith. +Require Import EqNat. + +Extract Inlined Constant Z.add => "(Prelude.+)". +Extract Inlined Constant Z.sub => "(Prelude.-)". +Extract Inlined Constant Z.mul => "(Prelude.*)". +Extract Inlined Constant Z.div => "Prelude.div". +Extract Inlined Constant Z.max => "Prelude.max". +Extract Inlined Constant Z.min => "Prelude.min". +Extract Inlined Constant Z_ge_lt_dec => "(Prelude.>=)". +Extract Inlined Constant Z_gt_le_dec => "(Prelude.>)". |
