never executed always true always false
1 module Conjure.Language.Attributes where
2
3 import Conjure.Language.Domain (BinaryRelationAttr (..))
4 import Conjure.Language.Expression.Op.Internal.Common (Lexeme (..))
5 import Conjure.Prelude
6 import Data.Map (Map)
7 import Data.Map.Strict qualified as M
8
9 type Attr = (Lexeme, Bool)
10
11 mapFrom :: [[Attr]] -> Map Lexeme Bool
12 mapFrom attrs = M.fromList $ concat attrs
13
14 setValidAttrs :: Map Lexeme Bool
15 setValidAttrs = mapFrom [sizeyAttrs]
16
17 msetValidAttrs :: Map Lexeme Bool
18 msetValidAttrs = mapFrom [sizeyAttrs, occursAttrs]
19
20 permValidAttrs :: Map Lexeme Bool
21 permValidAttrs = mapFrom [permAttrs]
22
23 funAttrs :: Map Lexeme Bool
24 funAttrs = mapFrom [sizeyAttrs, jectivityAttrs, totalityAttrs]
25
26 seqAttrs :: Map Lexeme Bool
27 seqAttrs = mapFrom [sizeyAttrs, jectivityAttrs]
28
29 relAttrs :: Map Lexeme Bool
30 relAttrs = mapFrom [sizeyAttrs, binRelAttrs, totalityAttrs]
31
32 partitionAttrs :: Map Lexeme Bool
33 partitionAttrs = mapFrom [sizeyAttrs, partSizeAttrs, partNumAttrs, regularity]
34
35 sizeyAttrs :: [Attr]
36 sizeyAttrs =
37 [ (L_size, True),
38 (L_maxSize, True),
39 (L_minSize, True)
40 ]
41
42 permAttrs :: [Attr]
43 permAttrs =
44 [ (L_numMoved, True),
45 (L_minNumMoved, True),
46 (L_maxNumMoved, True)
47 ]
48
49 occursAttrs :: [Attr]
50 occursAttrs =
51 [ (L_minOccur, True),
52 (L_maxOccur, True)
53 ]
54
55 partNumAttrs :: [Attr]
56 partNumAttrs =
57 [ (L_numParts, True),
58 (L_maxNumParts, True),
59 (L_minNumParts, True)
60 ]
61
62 partSizeAttrs :: [(Lexeme, Bool)]
63 partSizeAttrs =
64 [ (L_partSize, True),
65 (L_minPartSize, True),
66 (L_maxPartSize, True)
67 ]
68
69 jectivityAttrs :: [(Lexeme, Bool)]
70 jectivityAttrs =
71 [ (L_injective, False),
72 (L_bijective, False),
73 (L_surjective, False)
74 ]
75
76 binRelAttrs :: [(Lexeme, Bool)]
77 binRelAttrs =
78 [ (L_reflexive, False),
79 (L_irreflexive, False),
80 (L_coreflexive, False),
81 (L_symmetric, False),
82 (L_antiSymmetric, False),
83 (L_aSymmetric, False),
84 (L_transitive, False),
85 (L_total, False),
86 (L_connex, False),
87 (L_Euclidean, False),
88 (L_serial, False),
89 (L_equivalence, False),
90 (L_partialOrder, False),
91 (L_linearOrder, False),
92 (L_weakOrder, False),
93 (L_preOrder, False),
94 (L_strictPartialOrder, False),
95 (L_leftTotal, False),
96 (L_rightTotal, False)
97 ]
98
99 lexemeToBinRel :: Lexeme -> Maybe BinaryRelationAttr
100 lexemeToBinRel L_reflexive = Just BinRelAttr_Reflexive
101 lexemeToBinRel L_irreflexive = Just BinRelAttr_Irreflexive
102 lexemeToBinRel L_coreflexive = Just BinRelAttr_Coreflexive
103 lexemeToBinRel L_symmetric = Just BinRelAttr_Symmetric
104 lexemeToBinRel L_antiSymmetric = Just BinRelAttr_AntiSymmetric
105 lexemeToBinRel L_aSymmetric = Just BinRelAttr_ASymmetric
106 lexemeToBinRel L_transitive = Just BinRelAttr_Transitive
107 lexemeToBinRel L_total = Just BinRelAttr_Total
108 lexemeToBinRel L_connex = Just BinRelAttr_Connex
109 lexemeToBinRel L_Euclidean = Just BinRelAttr_Euclidean
110 lexemeToBinRel L_serial = Just BinRelAttr_Serial
111 lexemeToBinRel L_equivalence = Just BinRelAttr_Equivalence
112 lexemeToBinRel L_partialOrder = Just BinRelAttr_PartialOrder
113 lexemeToBinRel L_linearOrder = Just BinRelAttr_LinearOrder
114 lexemeToBinRel L_weakOrder = Just BinRelAttr_WeakOrder
115 lexemeToBinRel L_preOrder = Just BinRelAttr_PreOrder
116 lexemeToBinRel L_strictPartialOrder = Just BinRelAttr_StrictPartialOrder
117 lexemeToBinRel L_leftTotal = Just BinRelAttr_LeftTotal
118 lexemeToBinRel L_rightTotal = Just BinRelAttr_RightTotal
119 lexemeToBinRel _ = Nothing
120
121 totalityAttrs :: [Attr]
122 totalityAttrs = [(L_total, False)]
123
124 regularity :: [Attr]
125 regularity = [(L_regular, False)]
126
127 allAttributLexemes :: [Lexeme]
128 allAttributLexemes =
129 concatMap
130 (map fst)
131 [ sizeyAttrs,
132 jectivityAttrs,
133 occursAttrs,
134 partNumAttrs,
135 partSizeAttrs,
136 binRelAttrs,
137 totalityAttrs,
138 regularity,
139 permAttrs
140 ]