-----------------------------------------------------------------------------
-- Thih.Testbed:     Utility functions for constructing test samples
--
-- Part of `Typing Haskell in Haskell', version of November 23, 2000
-- Copyright (c) Mark P Jones and the Oregon Graduate Institute
-- of Science and Technology, 1999-2000
--
-- This program is distributed as Free Software under the terms
-- in the file "License" that is included in the distribution
-- of this software, copies of which may be obtained from:
--             http://www.cse.ogi.edu/~mpj/thih/
--
-----------------------------------------------------------------------------

module Thih.Testbed(module Thih.TI.PPrint,
               module Thih.TI.Id,
               module Thih.TI.Kind, module Thih.TI.Type, module Thih.TI.Pred, module Thih.TI.Scheme,
               module Thih.TI.Subst, module Thih.TI.Unify,
               module Thih.TI.Assump,
               module Thih.TI.Lit, module Thih.TI.Pat, module Thih.TI.TIMain, module Thih.TI.TIProg,
               module Thih.Static.Prim,
               test, save) where
import Thih.TI.PPrint
import Thih.TI.Id
import Thih.TI.Kind
import Thih.TI.Type
import Thih.TI.Pred
import Thih.TI.Scheme
import Thih.TI.Subst
import Thih.TI.Unify
import Thih.TI.Assump
import Thih.TI.Lit
import Thih.TI.Pat
import Thih.TI.TIMain
import Thih.TI.TIProg
import Thih.Static.Prim

test          :: ClassEnv -> [Assump] -> [BindGroup] -> IO ()
test ce as bgs = putStr $ render $ vcat $ map pprint $ reverse $
                 tiProgram' ce as bgs

save          :: String -> ClassEnv -> [Assump] -> [BindGroup] -> IO ()
save f ce as bgs
               = writeFile ("Haskell" ++ f ++".hs")
                 ("-- Automatically generated typing assumptions for " ++ f ++
                 "\n\nmodule Haskell" ++ f ++ " where\n\
                  \import Thih.Testbed\n\
                  \import Static" ++ f ++ "\n\n\
                  \defnsHaskell" ++ f ++ "\n" ++
                  render
                   (text " = " <+>
                     brackets (fsep (punctuate comma (map pprint as'))))
                                        ++ "\n")
                 where as' = reverse $ tiProgram' ce as bgs

-----------------------------------------------------------------------------
