69225
|
1 |
(* Title: Tools/Haskell/haskell.ml
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Support for Isabelle tools in Haskell.
|
|
5 |
*)
|
|
6 |
|
|
7 |
signature HASKELL =
|
|
8 |
sig
|
|
9 |
val generate_file_cmd: (string * Position.T) * Input.source ->
|
|
10 |
Toplevel.transition -> Toplevel.transition
|
|
11 |
val export_file_cmd: string * Input.source ->
|
|
12 |
Toplevel.transition -> Toplevel.transition
|
|
13 |
val source_modules: Path.T list
|
|
14 |
end;
|
|
15 |
|
|
16 |
structure Haskell: HASKELL =
|
|
17 |
struct
|
|
18 |
|
|
19 |
(* commands *)
|
|
20 |
|
69227
|
21 |
val header = "{- generated by Isabelle -}\n";
|
69225
|
22 |
|
|
23 |
fun generate_file_cmd (file, source) =
|
|
24 |
Toplevel.keep (fn state =>
|
|
25 |
let
|
|
26 |
val ctxt = Toplevel.context_of state;
|
|
27 |
val thy = Toplevel.theory_of state;
|
|
28 |
|
|
29 |
val path = Resources.check_path ctxt (Resources.master_directory thy) file;
|
|
30 |
val text = header ^ GHC.read_source ctxt source;
|
|
31 |
val _ = Isabelle_System.mkdirs (Path.dir (Path.expand path));
|
|
32 |
val _ = File.generate path text;
|
|
33 |
in () end);
|
|
34 |
|
|
35 |
fun export_file_cmd (name, source) =
|
|
36 |
Toplevel.keep (fn state =>
|
|
37 |
let
|
|
38 |
val ctxt = Toplevel.context_of state;
|
|
39 |
val thy = Toplevel.theory_of state;
|
|
40 |
|
|
41 |
val text = header ^ GHC.read_source ctxt source;
|
|
42 |
val _ = Export.export thy name [text];
|
|
43 |
in () end);
|
|
44 |
|
|
45 |
|
|
46 |
(* source modules *)
|
|
47 |
|
|
48 |
val source_modules =
|
|
49 |
[\<^file>\<open>~~/src/Tools/Haskell/Library.hs\<close>,
|
|
50 |
\<^file>\<open>~~/src/Tools/Haskell/Buffer.hs\<close>,
|
|
51 |
\<^file>\<open>~~/src/Tools/Haskell/Properties.hs\<close>,
|
|
52 |
\<^file>\<open>~~/src/Tools/Haskell/Markup.hs\<close>,
|
|
53 |
\<^file>\<open>~~/src/Tools/Haskell/XML.hs\<close>,
|
|
54 |
\<^file>\<open>~~/src/Tools/Haskell/YXML.hs\<close>];
|
|
55 |
|
|
56 |
end;
|