234 fun run in_path = |
234 fun run in_path = |
235 let |
235 let |
236 fun mk_code_file module = |
236 fun mk_code_file module = |
237 let |
237 let |
238 val (paths, base) = split_last module |
238 val (paths, base) = split_last module |
239 in Path.appends (in_path :: map Path.basic (paths @ [base ^ ".hs"])) end; |
239 in Path.appends (in_path :: map Path.basic (paths @ [suffix ".hs" base])) end; |
240 val generatedN = Code_Target.generatedN |
240 val generatedN_suffix = suffix ".hs" Code_Target.generatedN; |
241 val includes = AList.delete (op =) [generatedN] code_modules |
241 val includes = AList.delete (op =) [generatedN_suffix] code_modules |
242 |> (map o apfst) mk_code_file |
242 |> (map o apfst) mk_code_file |
243 val code = the (AList.lookup (op =) code_modules [generatedN]) |
243 val code = the (AList.lookup (op =) code_modules [generatedN_suffix]) |
244 val code_file = mk_code_file [generatedN] |
244 val code_file = mk_code_file [Code_Target.generatedN] |
245 val narrowing_engine_file = mk_code_file ["Narrowing_Engine"] |
245 val narrowing_engine_file = mk_code_file ["Narrowing_Engine"] |
246 val main_file = mk_code_file ["Main"] |
246 val main_file = mk_code_file ["Main"] |
247 val main = |
247 val main = |
248 "module Main where {\n\n" ^ |
248 "module Main where {\n\n" ^ |
249 "import System.IO;\n" ^ |
249 "import System.IO;\n" ^ |
250 "import System.Environment;\n" ^ |
250 "import System.Environment;\n" ^ |
251 "import Narrowing_Engine;\n" ^ |
251 "import Narrowing_Engine;\n" ^ |
252 "import " ^ generatedN ^ " ;\n\n" ^ |
252 "import " ^ Code_Target.generatedN ^ " ;\n\n" ^ |
253 "main = getArgs >>= \\[potential, size] -> " ^ |
253 "main = getArgs >>= \\[potential, size] -> " ^ |
254 "Narrowing_Engine.depthCheck (read potential) (read size) (" ^ generatedN ^ |
254 "Narrowing_Engine.depthCheck (read potential) (read size) (" ^ Code_Target.generatedN ^ |
255 ".value ())\n\n}\n" |
255 ".value ())\n\n}\n" |
256 val _ = |
256 val _ = |
257 map (uncurry File.write) |
257 map (uncurry File.write) |
258 (includes @ |
258 (includes @ |
259 [(narrowing_engine_file, |
259 [(narrowing_engine_file, |