forked from cartazio/haskabelle
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMain.hs
More file actions
53 lines (40 loc) · 1.62 KB
/
Main.hs
File metadata and controls
53 lines (40 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{-# OPTIONS_GHC -O -o bin/haskabelle_bin -odir build -hidir build -stubdir build #-}
{- Author: Florian Haftmann, TU Muenchen
Toplevel interface to Haskabelle importer.
-}
module Main where
import System.Environment (getArgs, getProgName)
import System.Exit (exitWith, ExitCode (ExitFailure))
import Importer.Conversion (importProject, importFiles)
import Importer.Adapt (readAdapt, Adaption (..))
import Importer.Configuration (readConfig)
import Importer.Version (version)
{-
Usage of the haskabelle binary:
haskabelle_bin --internal <ADAPT> <SRC1> .. <SRCn> <DST>
haskabelle_bin --internal <ADAPT> --config <CONFIG>
haskabelle_bin --version
Import Haskell files <SRC1> .. <SRCn> into Isabelle theories in directory
<DST>, optionally using customary adaption in directory <ADAPT> OR import
Haskell files according to configuration file <CONFIG>.
-}
mainInterface :: [String] -> IO ()
mainInterface ["--internal", adaptDir, "--config", configFile] = do
config <- readConfig configFile
importProject config adaptDir
mainInterface ("--internal" : adaptDir : srcs_dst @ (_ : _ : _)) =
importFiles adaptDir (init srcs_dst) (last srcs_dst)
mainInterface ("--internal" : args) = do
putStrLn "Error calling internal haskabelle binary. Wrong parameters:"
putStrLn (" " ++ show args)
mainInterface ("--version" : _) = do
putStrLn (version ++ ".")
mainInterface _ = do
putStrLn "Do not invoke linked Haskabelle binary directly"
putStrLn " -- invoke it as described in the Haskabelle manual."
putStrLn ""
putStrLn "Have a nice day!"
putStrLn ""
exitWith (ExitFailure 2)
main :: IO ()
main = getArgs >>= mainInterface