equal
deleted
inserted
replaced
405 then SOME (pr_stmt false (name, stmt)) |
405 then SOME (pr_stmt false (name, stmt)) |
406 else NONE |
406 else NONE |
407 | (_, (_, NONE)) => NONE) stmts)); |
407 | (_, (_, NONE)) => NONE) stmts)); |
408 val serialize_module = |
408 val serialize_module = |
409 if null stmt_names then serialize_module1 else pair "" o serialize_module2; |
409 if null stmt_names then serialize_module1 else pair "" o serialize_module2; |
|
410 fun check_destination destination = |
|
411 (File.check destination; destination); |
410 fun write_module destination (modlname, content) = |
412 fun write_module destination (modlname, content) = |
411 let |
413 let |
412 val filename = case modlname |
414 val filename = case modlname |
413 of "" => Path.explode "Main.hs" |
415 of "" => Path.explode "Main.hs" |
414 | _ => (Path.ext "hs" o Path.explode o implode o separate "/" |
416 | _ => (Path.ext "hs" o Path.explode o implode o separate "/" |
419 ("{-# OPTIONS_GHC -fglasgow-exts #-}\n\n" |
421 ("{-# OPTIONS_GHC -fglasgow-exts #-}\n\n" |
420 ^ Code_Target.code_of_pretty content) |
422 ^ Code_Target.code_of_pretty content) |
421 end |
423 end |
422 in |
424 in |
423 Code_Target.mk_serialization target NONE |
425 Code_Target.mk_serialization target NONE |
424 (fn NONE => K () o map (Code_Target.code_writeln o snd) | SOME file => K () o map (write_module file)) |
426 (fn NONE => K () o map (Code_Target.code_writeln o snd) | SOME file => K () o map |
|
427 (write_module (check_destination file))) |
425 (rpair [] o cat_lines o map (Code_Target.code_of_pretty o snd)) |
428 (rpair [] o cat_lines o map (Code_Target.code_of_pretty o snd)) |
426 (map (uncurry pr_module) includes |
429 (map (uncurry pr_module) includes |
427 @ map serialize_module (Symtab.dest hs_program)) |
430 @ map serialize_module (Symtab.dest hs_program)) |
428 destination |
431 destination |
429 end; |
432 end; |