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
|
module CurryInterface.Files where
import System.CurryPath ( getLoadPathForModule, inCurrySubdir
, lookupModuleSourceInLoadPath, stripCurrySuffix )
import System.Directory ( doesFileExist )
import System.FilePath ( takeFileName, (</>), (<.>) )
import System.FrontendExec
import CurryInterface.Parser
import CurryInterface.Types
readCurryInterface :: String -> IO Interface
readCurryInterface modname =
readCurryInterfaceWithParseOptions modname (setQuiet True defaultParams)
readCurryInterfaceWithParseOptions :: String -> FrontendParams -> IO Interface
readCurryInterfaceWithParseOptions modname options = do
mbsrc <- lookupModuleSourceInLoadPath modname
case mbsrc of
Nothing -> error $ "Module '" ++ modname ++ "' not found in load path!"
Just (dir,_) -> do
callFrontendWithParams FCY options modname
readCurryInterfaceFile (curryInterfaceFileName (dir </> modname))
curryInterfaceFileName :: String -> String
curryInterfaceFileName prog = inCurrySubdir (stripCurrySuffix prog) <.> "icurry"
readCurryInterfaceFile :: String -> IO Interface
readCurryInterfaceFile filename = do
exacy <- doesFileExist filename
if exacy
then readExistingICURRY filename
else error $ "EXISTENCE ERROR: Curry interface file '" ++ filename ++
"' does not exist"
where
readExistingICURRY fname = do
icurrystring <- readFile fname
return $ parseCurryInterface icurrystring
|