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
|
module ArityMap where
import FiniteMap
import AbstractCurry.Files
import AbstractCurry.Select
import AbstractCurry.Types
import Distribution (installDir)
import List (nub,partition)
import Directory (doesFileExist)
import Unsafe (unsafePerformIO)
import FilePath ((<.>))
buildArityMap:: [String] -> IO (FM QName Int)
buildArityMap files =
do
acfuncs <- mapIO readCurry ("Prelude":files)
let imps = (concatMap imports acfuncs)
(selfs,libs) = partition ( unsafePerformIO
. doesFileExist
. (<.> "curry"))
imps
impFuncs <- mapIO readCurry (selfs++libs)
let totalFuncs = impFuncs++acfuncs
let acArities = map extractArity (concatMap functions totalFuncs)
return $ (addListToFM (emptyFM (<)) acArities)
extractArity:: CFuncDecl -> (QName, Arity)
(CFunc qName ar _ _ _) = (qName,ar)
extractArity (CmtFunc _ qName ar _ _ _) = (qName,ar)
path:: String
path = installDir++"/lib/"
|