Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Common/CExtraction.v
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,22 @@ From Stdlib Require Import Zeuclid.
From Stdlib Require Import Extraction.

Require Import Options.
Require Import Common HVec Exec.
Require Import Common Effects HVec Exec.


(** * Base defaults *)

From Stdlib Require Import ExtrOcamlBasic.


Extraction Inline fmap.
Extraction Inline mbind.
Extraction Inline mcall.
Extraction Inline mchoose.
Extraction Inline lookup_total.
Extraction Inline mchoosel.
Extraction Inline mret.

(** * Bools *)

Extract Inlined Constant Decision => "bool".
Expand Down Expand Up @@ -328,7 +336,9 @@ Extract Inlined Constant HexString.of_Z => "Support.hex_str_of_Z".

(** * Lists *)

Extract Inlined Constant map => "Stdlib.List.map".
Extract Inlined Constant map => "Support.list_map".
Extract Inlined Constant list_fmap => "Support.list_map".
(* Extract Inlined Constant map => "Stdlib.List.map". *)
Extract Inlined Constant length => "Support.lengthZ".

Extraction Blacklist List.
Expand Down Expand Up @@ -358,7 +368,7 @@ Extract Inductive vec => list [ "[]" "( :: )" ].
Extraction Implicit vnil [A].
Extraction Implicit vcons [A n].
Extraction Implicit vmap [A B n].
Extract Inlined Constant vmap => "List.map".
Extract Inlined Constant vmap => "Support.list_map".
Extract Inlined Constant list_to_vec => "(fun x -> x)".

Extraction Implicit Vector.last [A n].
Expand Down
10 changes: 10 additions & 0 deletions Extraction/support.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,13 @@ let bv_extract o l z =
else
let o = Z.to_int o in
Z.extract z o l

let[@tail_mod_cons] rec list_map f = function
| [] -> []
| [a1] ->
let r1 = f a1 in
[r1]
| a1 :: a2 :: l ->
let r1 = f a1 in
let r2 = f a2 in
r1 :: r2 :: list_map f l
Loading