equal
deleted
inserted
replaced
5 *) |
5 *) |
6 |
6 |
7 signature CODE_HASKELL = |
7 signature CODE_HASKELL = |
8 sig |
8 sig |
9 val target: string |
9 val target: string |
10 val check: theory -> unit |
|
11 val setup: theory -> theory |
10 val setup: theory -> theory |
12 end; |
11 end; |
13 |
12 |
14 structure Code_Haskell : CODE_HASKELL = |
13 structure Code_Haskell : CODE_HASKELL = |
15 struct |
14 struct |
462 |> Code_Target.add_syntax_const target c_bind |
461 |> Code_Target.add_syntax_const target c_bind |
463 (SOME (pretty_haskell_monad c_bind)) |
462 (SOME (pretty_haskell_monad c_bind)) |
464 else error "Only Haskell target allows for monad syntax" end; |
463 else error "Only Haskell target allows for monad syntax" end; |
465 |
464 |
466 |
465 |
467 (** formal checking of compiled code **) |
|
468 |
|
469 fun check thy = Code_Target.external_check thy target |
|
470 "EXEC_GHC" I (fn ghc => fn p => fn module_name => |
|
471 ghc ^ " -fglasgow-exts -odir build -hidir build -stubdir build -e \"\" " ^ module_name ^ ".hs"); |
|
472 |
|
473 |
|
474 |
|
475 (** Isar setup **) |
466 (** Isar setup **) |
476 |
467 |
477 fun isar_serializer module_name = |
468 fun isar_serializer module_name = |
478 Code_Target.parse_args (Scan.option (Args.$$$ "root" -- Args.colon |-- Args.name) |
469 Code_Target.parse_args (Scan.option (Args.$$$ "root" -- Args.colon |-- Args.name) |
479 -- Scan.optional (Args.$$$ "string_classes" >> K true) false |
470 -- Scan.optional (Args.$$$ "string_classes" >> K true) false |
486 Toplevel.theory (add_monad target raw_bind)) |
477 Toplevel.theory (add_monad target raw_bind)) |
487 ); |
478 ); |
488 |
479 |
489 val setup = |
480 val setup = |
490 Code_Target.add_target |
481 Code_Target.add_target |
491 (target, { serializer = isar_serializer, literals = literals, check = () }) |
482 (target, { serializer = isar_serializer, literals = literals, |
|
483 check = { env_var = "EXEC_GHC", make_destination = I, |
|
484 make_command = fn ghc => fn p => fn module_name => |
|
485 ghc ^ " -fglasgow-exts -odir build -hidir build -stubdir build -e \"\" " ^ module_name ^ ".hs" } }) |
492 #> Code_Target.add_syntax_tyco target "fun" (SOME (2, fn print_typ => fn fxy => fn [ty1, ty2] => |
486 #> Code_Target.add_syntax_tyco target "fun" (SOME (2, fn print_typ => fn fxy => fn [ty1, ty2] => |
493 brackify_infix (1, R) fxy ( |
487 brackify_infix (1, R) fxy ( |
494 print_typ (INFX (1, X)) ty1, |
488 print_typ (INFX (1, X)) ty1, |
495 str "->", |
489 str "->", |
496 print_typ (INFX (1, R)) ty2 |
490 print_typ (INFX (1, R)) ty2 |