src/Tools/Code/code_haskell.ML
changeset 39056 fa197571676b
parent 39055 81e0368812ad
child 39057 c6d146ed07ae
equal deleted inserted replaced
39055:81e0368812ad 39056:fa197571676b
   379           then "import qualified "
   379           then "import qualified "
   380           else "import ") ^ name ^ ";");
   380           else "import ") ^ name ^ ";");
   381         val import_ps = map print_import_include includes @ map print_import_module imports
   381         val import_ps = map print_import_include includes @ map print_import_module imports
   382         val content = Pretty.chunks2 ((if null import_ps then [] else [Pretty.chunks import_ps])
   382         val content = Pretty.chunks2 ((if null import_ps then [] else [Pretty.chunks import_ps])
   383             @ map_filter
   383             @ map_filter
   384               (fn (name, (_, SOME stmt)) => SOME (print_stmt qualified (name, stmt))
   384               (fn (name, (_, SOME stmt)) => SOME (markup_stmt name (print_stmt qualified (name, stmt)))
   385                 | (_, (_, NONE)) => NONE) stmts
   385                 | (_, (_, NONE)) => NONE) stmts
   386           );
   386           );
   387       in print_module module_name' content end;
   387       in print_module module_name' content end;
   388     fun serialize_module2 (_, (_, (stmts, _))) = Pretty.chunks2 (map_filter
   388     fun serialize_module2 (_, (_, (stmts, _))) = Pretty.chunks2 (map_filter
   389         (fn (name, (_, SOME stmt)) => if null presentation_names
   389         (fn (name, (_, SOME stmt)) => if null presentation_names
   402                     o Long_Name.explode) modlname;
   402                     o Long_Name.explode) modlname;
   403             val pathname = Path.append destination filename;
   403             val pathname = Path.append destination filename;
   404             val _ = File.mkdir_leaf (Path.dir pathname);
   404             val _ = File.mkdir_leaf (Path.dir pathname);
   405           in File.write pathname
   405           in File.write pathname
   406             ("{-# OPTIONS_GHC -fglasgow-exts #-}\n\n"
   406             ("{-# OPTIONS_GHC -fglasgow-exts #-}\n\n"
   407               ^ format false width content)
   407               ^ format [] width content)
   408           end
   408           end
   409       | write_module width NONE (_, content) = writeln (format false width content);
   409       | write_module width NONE (_, content) = writeln (format [] width content);
   410   in
   410   in
   411     Code_Target.serialization
   411     Code_Target.serialization
   412       (fn width => fn destination => K () o map (write_module width destination))
   412       (fn width => fn destination => K () o map (write_module width destination))
   413       (fn present => fn width => rpair [] o format present width o Pretty.chunks o map snd)
   413       (fn present => fn width => rpair [] o format present width o Pretty.chunks o map snd)
   414       (map (uncurry print_module) includes
   414       (map (uncurry print_module) includes