aboutsummaryrefslogtreecommitdiff
path: root/plugins/extraction/haskell.ml
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2015-03-23 13:10:34 +0100
committerPierre-Marie Pédrot2015-03-23 13:10:34 +0100
commit224d3b0e8be9b6af8194389141c9508504cf887c (patch)
treee36a175c48d3b7c6bdd10eb9907f726af7f3a9e7 /plugins/extraction/haskell.ml
parent690ac9fe35ff153a2348b64984817cb37b7764e4 (diff)
parent3646aea90ae927af9262e994048a3bd863c57839 (diff)
Merge branch 'v8.5'
Diffstat (limited to 'plugins/extraction/haskell.ml')
-rw-r--r--plugins/extraction/haskell.ml14
1 files changed, 9 insertions, 5 deletions
diff --git a/plugins/extraction/haskell.ml b/plugins/extraction/haskell.ml
index 5e08fef5fe..52459f78eb 100644
--- a/plugins/extraction/haskell.ml
+++ b/plugins/extraction/haskell.ml
@@ -26,7 +26,7 @@ let pr_upper_id id = str (String.capitalize (Id.to_string id))
let keywords =
List.fold_right (fun s -> Id.Set.add (Id.of_string s))
- [ "case"; "class"; "data"; "default"; "deriving"; "do"; "else";
+ [ "Any"; "case"; "class"; "data"; "default"; "deriving"; "do"; "else";
"if"; "import"; "in"; "infix"; "infixl"; "infixr"; "instance";
"let"; "module"; "newtype"; "of"; "then"; "type"; "where"; "_"; "__";
"as"; "qualified"; "hiding" ; "unit" ; "unsafeCoerce" ]
@@ -56,11 +56,14 @@ let preamble mod_name comment used_modules usf =
else str "\
\n#ifdef __GLASGOW_HASKELL__\
\nimport qualified GHC.Base\
+\nimport qualified GHC.Prim\
+\ntype Any = GHC.Prim.Any\
\nunsafeCoerce :: a -> b\
\nunsafeCoerce = GHC.Base.unsafeCoerce#\
\n#else\
\n-- HUGS\
\nimport qualified IOExts\
+\ntype Any = ()\
\nunsafeCoerce :: a -> b\
\nunsafeCoerce = IOExts.unsafeCoerce\
\n#endif" ++ fnl2 ())
@@ -102,7 +105,7 @@ let rec pp_type par vl t =
pp_par par
(pp_rec true t1 ++ spc () ++ str "->" ++ spc () ++ pp_rec false t2)
| Tdummy _ -> str "()"
- | Tunknown -> str "()"
+ | Tunknown -> str "Any"
| Taxiom -> str "() -- AXIOM TO BE REALIZED\n"
in
hov 0 (pp_rec par t)
@@ -243,12 +246,12 @@ let pp_logical_ind packet =
prvect_with_sep spc pr_id packet.ip_consnames)
let pp_singleton kn packet =
+ let name = pp_global Type (IndRef (kn,0)) in
let l = rename_tvars keywords packet.ip_vars in
- let l' = List.rev l in
- hov 2 (str "type " ++ pp_global Type (IndRef (kn,0)) ++ spc () ++
+ hov 2 (str "type " ++ name ++ spc () ++
prlist_with_sep spc pr_id l ++
(if not (List.is_empty l) then str " " else mt ()) ++ str "=" ++ spc () ++
- pp_type false l' (List.hd packet.ip_types.(0)) ++ fnl () ++
+ pp_type false l (List.hd packet.ip_types.(0)) ++ fnl () ++
pp_comment (str "singleton inductive, whose constructor was " ++
pr_id packet.ip_consnames.(0)))
@@ -360,6 +363,7 @@ let pp_struct =
let haskell_descr = {
keywords = keywords;
file_suffix = ".hs";
+ file_naming = string_of_modfile;
preamble = preamble;
pp_struct = pp_struct;
sig_suffix = None;