aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/extraction/haskell.ml
diff options
context:
space:
mode:
authorGravatar Nickolai Zeldovich <nickolai@csail.mit.edu>2015-04-02 21:46:19 +0200
committerGravatar Guillaume Melquiond <guillaume.melquiond@inria.fr>2015-04-02 21:46:34 +0200
commit6950837dd6e2a3a2bc3c3d748d06054a625bc661 (patch)
tree6f3cc7461b1ffc6e547c420bbbb577f63f76e51b /plugins/extraction/haskell.ml
parentaec237038d300ce7c81dddd154cbdc93fed5b226 (diff)
Puts all the "import" statements first so as to accommodate the latest GHC.
Diffstat (limited to 'plugins/extraction/haskell.ml')
-rw-r--r--plugins/extraction/haskell.ml13
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/extraction/haskell.ml b/plugins/extraction/haskell.ml
index 5f31edfb6..37b414207 100644
--- a/plugins/extraction/haskell.ml
+++ b/plugins/extraction/haskell.ml
@@ -52,15 +52,23 @@ let preamble mod_name comment used_modules usf =
str "import qualified Prelude" ++ fnl () ++
prlist pp_import used_modules ++ fnl () ++
(if List.is_empty used_modules then mt () else fnl ()) ++
- (if not usf.magic then mt ()
+ (if not (usf.magic || usf.tunknown) then mt ()
else str "\
\n#ifdef __GLASGOW_HASKELL__\
\nimport qualified GHC.Base\
+\nimport qualified GHC.Prim\
+\n#else\
+\n-- HUGS\
+\nimport qualified IOExts\
+\n#endif" ++ fnl2 ())
+ ++
+ (if not usf.magic then mt ()
+ else str "\
+\n#ifdef __GLASGOW_HASKELL__\
\nunsafeCoerce :: a -> b\
\nunsafeCoerce = GHC.Base.unsafeCoerce#\
\n#else\
\n-- HUGS\
-\nimport qualified IOExts\
\nunsafeCoerce :: a -> b\
\nunsafeCoerce = IOExts.unsafeCoerce\
\n#endif" ++ fnl2 ())
@@ -68,7 +76,6 @@ let preamble mod_name comment used_modules usf =
(if not usf.tunknown then mt ()
else str "\
\n#ifdef __GLASGOW_HASKELL__\
-\nimport qualified GHC.Prim\
\ntype Any = GHC.Prim.Any\
\n#else\
\n-- HUGS\