author | wenzelm |
Wed, 03 Apr 2019 21:50:00 +0200 | |
changeset 70047 | 96fe857a7a6f |
parent 69662 | fd86ed39aea4 |
child 70082 | 4f936de6d9b8 |
permissions | -rw-r--r-- |
69241 | 1 |
(* Title: Tools/Haskell/Test.thy |
69225 | 2 |
Author: Makarius |
3 |
*) |
|
4 |
||
69241 | 5 |
section \<open>Test build of Isabelle/Haskell modules\<close> |
69225 | 6 |
|
69241 | 7 |
theory Test imports Haskell |
69225 | 8 |
begin |
9 |
||
69239
6cd985a78d6e
support sub-directories, i.e. structure module names;
wenzelm
parents:
69225
diff
changeset
|
10 |
ML \<open> |
69444
c3c9440cbf9b
more formal Haskell project setup, with dependencies on packages from "stackage";
wenzelm
parents:
69385
diff
changeset
|
11 |
Isabelle_System.with_tmp_dir "ghc" (fn tmp_dir => |
69225 | 12 |
let |
69444
c3c9440cbf9b
more formal Haskell project setup, with dependencies on packages from "stackage";
wenzelm
parents:
69385
diff
changeset
|
13 |
val src_dir = Path.append tmp_dir (Path.explode "src"); |
70047
96fe857a7a6f
clarified signature: more explicit operations for corresponding Isar commands;
wenzelm
parents:
69662
diff
changeset
|
14 |
val files = Generated_Files.get_files \<^theory>\<open>Haskell\<close>; |
96fe857a7a6f
clarified signature: more explicit operations for corresponding Isar commands;
wenzelm
parents:
69662
diff
changeset
|
15 |
val _ = List.app (Generated_Files.write_file src_dir) files; |
69444
c3c9440cbf9b
more formal Haskell project setup, with dependencies on packages from "stackage";
wenzelm
parents:
69385
diff
changeset
|
16 |
|
c3c9440cbf9b
more formal Haskell project setup, with dependencies on packages from "stackage";
wenzelm
parents:
69385
diff
changeset
|
17 |
val modules = files |
70047
96fe857a7a6f
clarified signature: more explicit operations for corresponding Isar commands;
wenzelm
parents:
69662
diff
changeset
|
18 |
|> map (#path #> Path.implode #> unsuffix ".hs" #> space_explode "/" #> space_implode "."); |
69446 | 19 |
val _ = |
20 |
GHC.new_project tmp_dir |
|
69453 | 21 |
{name = "isabelle", |
69473 | 22 |
depends = |
23 |
["bytestring", "containers", "network", "split", "threads", "utf8-string", "uuid"], |
|
69453 | 24 |
modules = modules}; |
69444
c3c9440cbf9b
more formal Haskell project setup, with dependencies on packages from "stackage";
wenzelm
parents:
69385
diff
changeset
|
25 |
|
69225 | 26 |
val (out, rc) = |
27 |
Isabelle_System.bash_output |
|
69444
c3c9440cbf9b
more formal Haskell project setup, with dependencies on packages from "stackage";
wenzelm
parents:
69385
diff
changeset
|
28 |
(cat_lines ["set -e", "cd " ^ File.bash_path tmp_dir, "isabelle ghc_stack build 2>&1"]); |
69239
6cd985a78d6e
support sub-directories, i.e. structure module names;
wenzelm
parents:
69225
diff
changeset
|
29 |
in if rc = 0 then writeln out else error out end) |
69225 | 30 |
\<close> |
31 |
||
32 |
end |