ResiduationStats.curry 1.96 KB
Newer Older
Michael Hanus's avatar
Michael Hanus committed
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--- Analyzing the residuation behavior of a module and returns
--- some statistical information.

import List ( intercalate, partition )

import FlatCurry.Types ( QName )
import CASS.Server           ( analyzeGeneric )
import Analysis.ProgInfo     ( progInfo2Lists )
import Analysis.Residuation -- ( demandAnalysis )

residuationInfoOf :: String
                  -> IO ([(QName,ResiduationInfo)],[(QName,ResiduationInfo)])
residuationInfoOf modname = do
  analyzeGeneric residuationAnalysis modname
    >>= return . either progInfo2Lists error

countResOps :: String -> IO [String]
countResOps mname = do
  putStrLn $ "Analyzing module " ++ mname ++ "..."
  (pubres,privres) <- residuationInfoOf mname
  let (resops,nonresops) = partition (\(_,i) -> i==MayResiduate || i==NoResInfo)
                                     (pubres ++ privres)
  return [mname, show (length resops), show (length nonresops)]

printCountResOps :: [String] -> IO ()
printCountResOps mname = do
  stats <- mapIO countResOps mname
  putStrLn $ "Module | Residuating | Non-residuating"
  mapIO_ (\row -> putStrLn (intercalate "|" row)) stats
  
main :: IO ()
main = printCountResOps baseModules
  
baseModules :: [String]
baseModules = ["Prelude","List","Char"]

allBaseModules :: [String]
allBaseModules =
  ["AllSolutions"
  ,"AnsiCodes"
  ,"Char"
  ,"Combinatorial"
  ,"CPNS"
  ,"Debug"
  ,"Dequeue"
  ,"Directory"
  ,"Distribution"
  ,"Either"
  ,"ErrorState"
  ,"FileGoodies"
  ,"FilePath"
  ,"Findall"
  ,"FiniteMap"
  ,"Float"
  ,"Format"
  ,"Function"
  ,"FunctionInversion"
  ,"GetOpt"
  ,"Global"
  ,"Integer"
  ,"IO"
  ,"IOExts"
  ,"List"
  ,"Maybe"
  ,"NamedSocket"
  ,"Nat"
  ,"Prelude"
  ,"Profile"
  ,"PropertyFile"
  ,"Random"
  ,"Read"
  ,"ReadNumeric"
  ,"ReadShowTerm"
  ,"RedBlackTree"
  ,"SearchTree"
  ,"SearchTreeGenerators"
  ,"SearchTreeTraversal"
  ,"SetFunctions"
  ,"SetRBT"
  ,"ShowS"
  ,"Socket"
  ,"Sort"
  ,"State"
  ,"System"
  ,"TableRBT"
  ,"Time"
  ,"Traversal"
  ,"Unsafe"
  ,"ValueSequence"
  ]