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
54
55
56
57
58
|
module Imports(getImportedInterfaces,moduleImports,readFlatCurryFileInLoadPath,
InterfaceOrFlatProg(..),ifOrProg,progOfIFFP)
where
import Directory
import FileGoodies
import Maybe
import FlatCurry.Types
import FlatCurry.Files
import FlatCurry.Goodies
import FlatCurry.Read
import System.CurryPath ( getLoadPathForModule )
getImportedInterfaces :: String -> IO [(String,InterfaceOrFlatProg)]
getImportedInterfaces mod = do
imps <- readFlatCurryIntWithImports mod
return (map (\prog -> (progName prog, IF prog)) imps)
moduleImports :: Prog -> (String, [String])
moduleImports (Prog m is _ _ _) = (m, is)
data InterfaceOrFlatProg = IF Prog | FP Prog
ifOrProg :: (Prog->a) -> (Prog->a) -> InterfaceOrFlatProg -> a
ifOrProg iffun _ (IF prog) = iffun prog
ifOrProg _ fpfun (FP prog) = fpfun prog
progOfIFFP :: InterfaceOrFlatProg -> Prog
progOfIFFP (IF prog) = prog
progOfIFFP (FP prog) = prog
readFlatCurryFileInLoadPath :: (String -> IO _) -> String -> [String] -> IO Prog
readFlatCurryFileInLoadPath prt mod loadpath = do
mbfcyfile <- lookupFileInPath (flatCurryFileName mod) [""] loadpath
maybe (error $ "FlatCurry file of module "++mod++" not found!")
(readFlatCurryFileAndReport prt mod)
mbfcyfile
readFlatCurryFileAndReport :: (String -> IO _) -> String -> String -> IO Prog
readFlatCurryFileAndReport prt mod filename = do
size <- fileSize filename
prt $ "Reading FlatCurry file of module '"++mod++"' ("++show size++" bytes)..."
prog <- readFlatCurryFile filename
seq (prog==prog) (return prog)
|