2 Maitainer : jmvilaca@di.uminho.pt
27 type INRules g n e = [INRule g n e]
29 -- | Empty set of rules.
30 empty :: (InfoKind e g, InfoKind n g) => g -> n -> e -> INRules g n e
34 updateRule :: String -> (INRule g n e -> INRule g n e)
35 -> INRules g n e -> INRules g n e
36 updateRule ruleName ruleFunc rules = map f rules
37 where f rule | ruleName == getName rule = ruleFunc rule
40 rulesNames :: INRules g n e -> [String]
41 rulesNames = map getName
43 sameName :: String -> INRule g n e -> Bool
44 sameName ruleName rule = (getName rule) == ruleName
46 findRule :: String -> INRules g n e -> Maybe (INRule g n e)
47 findRule ruleName rules = find (sameName ruleName) rules
49 fromRule :: (INRule g n e -> x) -> String -> INRules g n e -> Maybe x
50 fromRule func ruleName rules =
51 case findRule ruleName rules of
52 Just rule -> Just $ func rule
55 addNewRule :: INRule g n e -> INRules g n e -> INRules g n e
56 addNewRule newRule rules = rules ++ [newRule]
58 addNewEmptyRule :: (InfoKind e g, InfoKind n g) =>
59 String -> g -> n -> e -> INRules g n e -> INRules g n e
60 addNewEmptyRule ruleName g n e rules =
61 let newRule = setName ruleName $ initial g n e
62 in addNewRule newRule rules
64 removeRule :: (InfoKind e g, InfoKind n g) =>
65 String -> INRules g n e -> INRules g n e
66 removeRule ruleName rules = filter (not . sameName ruleName) rules
68 mapRules :: (INRule g n e -> x) -> INRules g n e -> [x]