src/Tools/Haskell/Test.thy
author wenzelm
Mon, 10 Dec 2018 23:36:29 +0100
changeset 69446 9cf0b79dfb7f
parent 69444 c3c9440cbf9b
child 69453 dcea1fffbfe6
permissions -rw-r--r--
more Haskell operations;

(*  Title:      Tools/Haskell/Test.thy
    Author:     Makarius
*)

section \<open>Test build of Isabelle/Haskell modules\<close>

theory Test imports Haskell
begin

ML \<open>
  Isabelle_System.with_tmp_dir "ghc" (fn tmp_dir =>
    let
      val src_dir = Path.append tmp_dir (Path.explode "src");
      val files = Generated_Files.write_files \<^theory>\<open>Haskell\<close> src_dir;

      val modules = files
        |> map (Path.implode #> unsuffix ".hs" #> space_explode "/" #> space_implode ".");
      val _ =
        GHC.new_project tmp_dir
          {name = "isabelle", depends = ["bytestring", "utf8-string", "network"], modules = modules};

      val (out, rc) =
        Isabelle_System.bash_output
          (cat_lines ["set -e", "cd " ^ File.bash_path tmp_dir, "isabelle ghc_stack build 2>&1"]);
    in if rc = 0 then writeln out else error out end)
\<close>

end