only write ghc pragma when writing to a file
authorhaftmann
Tue, 07 Sep 2010 16:49:32 +0200
changeset 39209 1ca9055ba1f7
parent 39208 fc1e02735438
child 39210 985b13c5a61d
only write ghc pragma when writing to a file
src/Tools/Code/code_haskell.ML
--- a/src/Tools/Code/code_haskell.ML	Tue Sep 07 16:37:23 2010 +0200
+++ b/src/Tools/Code/code_haskell.ML	Tue Sep 07 16:49:32 2010 +0200
@@ -329,8 +329,7 @@
       map (fn (name, _) => str ("import qualified " ^ name ^ ";")) includes;
     fun print_module_frame module_name ps =
       (module_name, Pretty.chunks2 (
-        str "{-# OPTIONS_GHC -fglasgow-exts #-}"
-        :: str ("module " ^ module_name ^ " where {")
+        str ("module " ^ module_name ^ " where {")
         :: ps
         @| str "}"
       ));
@@ -355,7 +354,10 @@
             val filepath = (Path.append destination o Path.ext "hs" o Path.explode o implode
               o separate "/" o Long_Name.explode) module_name;
             val _ = File.mkdir_leaf (Path.dir filepath);
-          in File.write filepath (format [] width content) end
+          in
+            (File.write filepath o format [] width o Pretty.chunks2)
+              [str "{-# OPTIONS_GHC -fglasgow-exts #-}", content]
+          end
       | write_module width NONE (_, content) = writeln (format [] width content);
   in
     Code_Target.serialization