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
|
module CurryBrowseAnalysis.Nondeterminism(analyseNondeterminism,analyseSetValued) where
import FlatCurry.Types
import CurryBrowseAnalysis.Overlapping(orInExpr)
import CurryBrowseAnalysis.Dependency(analyseWithDependencies)
analyseNondeterminism :: [FuncDecl] -> [(QName,Bool)]
analyseNondeterminism = analyseWithDependencies isNondeterministicDefined or
isNondeterministicDefined :: FuncDecl -> Bool
isNondeterministicDefined (Func _ _ _ _ rule) = isNondeterministicRule rule
isNondeterministicRule :: Rule -> Bool
isNondeterministicRule (Rule _ e) = orInExpr e
isNondeterministicRule (External _) = False
analyseSetValued :: [FuncDecl] -> [(QName,Bool)]
analyseSetValued = analyseWithDependencies isSetValuedDefined or
isSetValuedDefined :: FuncDecl -> Bool
isSetValuedDefined (Func f _ _ _ rule) =
f `notElem` [pre "failed",pre "$!!",pre "$##"] && isSetValuedRule rule
isSetValuedRule :: Rule -> Bool
isSetValuedRule (Rule _ e) = orInExpr e || extraVarInExpr e
isSetValuedRule (External _) = False
extraVarInExpr :: Expr -> Bool
(Var _) = False
extraVarInExpr (Lit _) = False
extraVarInExpr (Comb _ _ es) = or (map extraVarInExpr es)
extraVarInExpr (Free vars e) = (not (null vars)) || extraVarInExpr e
extraVarInExpr (Let bs e) = any extraVarInExpr (map snd bs) || extraVarInExpr e
extraVarInExpr (Or e1 e2) = extraVarInExpr e1 || extraVarInExpr e2
extraVarInExpr (Case _ e bs) = extraVarInExpr e || any extraVarInBranch bs
where (Branch _ be) = extraVarInExpr be
extraVarInExpr (Typed e _) = extraVarInExpr e
pre :: String -> QName
pre n = ("Prelude",n)
|