cleaned up lots of FIXMEs in ProofToLatex
[coq-hetmet.git] / src / Extraction.v
1 (* need this or the Haskell extraction fails *)
2 Set Printing Width 1300000.
3
4 Require Import Coq.Lists.List.
5 Require Import Coq.Strings.Ascii.
6 Require Import Coq.Strings.String.
7 Require Import Main.
8 Require Import HaskCoreVars.
9 Require Import HaskCore.
10
11 Open Scope string_scope.
12 Extraction Language Haskell.
13
14 (* I try to reuse Haskell types mostly to get the "deriving Show" aspect *)
15 Extract Inductive option => "Prelude.Maybe" [ "Prelude.Just" "Prelude.Nothing" ].
16 Extract Inductive list   => "([])" [ "([])" "(:)" ].
17 (*Extract Inductive vec    => "([])" [ "([])" "(:)" ].*)
18 (*Extract Inductive Tree   => "([])" [ "([])" "(:)" ].*)
19 Extract Inlined Constant map => "Prelude.map".
20 Extract Inductive string => "Prelude.String" [ "([])" "(:)" ].
21 Extract Inductive prod   => "(,)" [ "(,)" ].
22 Extract Inductive sum    => "Prelude.Either" [ "Prelude.Left" "Prelude.Right" ].
23 Extract Inductive sumbool => "Prelude.Bool" [ "Prelude.True" "Prelude.False" ].
24 Extract Inductive bool    => "Prelude.Bool" [ "Prelude.True" "Prelude.False" ].
25 Extract Inductive unit    => "()" [ "()" ].
26 Extract Inlined Constant string_dec => "(==)".
27 Extract Inlined Constant ascii_dec => "(==)".
28 Extract Inductive string => "Prelude.String" [ "[]" "(:)" ].
29
30 (* adapted from ExtrOcamlString.v *)
31 Extract Inductive ascii => "Prelude.Char"
32 [
33 "{- If this appears, you're using Ascii internals. Please don't -} (\ b0 b1 b2 b3 b4 b5 b6 b7 ->   let f b i = if b then 1 `shiftL` i else 0 in Data.Char.chr (f b0 0 .|. f b1 1 .|. f b2 2 .|. f b3 3 .|. f b4 4 .|. f b5 5 .|. f b6 6 .|. f b7 7))"
34 ]
35 "{- If this appears, you're using Ascii internals. Please don't -} (\ f c -> let n = Char.code c in let h i = (n .&. (1 `shiftL` i)) /= 0 in f (h 0) (h 1) (h 2) (h 3) (h 4) (h 5) (h 6) (h 7))".
36 Extract Constant zero  => "'\000'".
37 Extract Constant one   => "'\001'".
38 Extract Constant shift => "\ b c -> Data.Char.chr (((Char.code c) `shiftL` 1) .&. 255 .|. if b then 1 else 0)".
39
40 Unset Extraction Optimize.
41 Unset Extraction AutoInline.
42
43 Definition coqCoreToStringPass (s:CoreExpr CoreVar) : string
44    := "FIXME".
45 (*
46 Definition coqCoreToCorePass (s:CoreExpr CoreVar) : CoreExpr CoreVar
47    :=
48 *)
49
50 Extraction "Extraction.hs" coqCoreToStringPass.
51