1module ProjectM36.AttributeNames where
2import qualified ProjectM36.Attribute as A
5import qualified Data.Set as S
6--AttributeNames is a data structure which can represent inverted projection attributes
9empty = AttributeNames S.empty
12all = InvertedAttributeNames S.empty
14--check that the attribute names are actually in the attributes
15projectionAttributesForAttributeNames :: Attributes -> AttributeNames -> Either RelationalError Attributes
16projectionAttributesForAttributeNames attrs (AttributeNames attrNameSet) = do
17 let nonExistentAttributeNames = A.attributeNamesNotContained attrNameSet (A.attributeNameSet attrs)
18 if not $ S.null nonExistentAttributeNames then
19 Left $ AttributeNamesMismatchError nonExistentAttributeNames
21 return $ A.attributesForNames attrNameSet attrs
22projectionAttributesForAttributeNames attrs (InvertedAttributeNames unselectedAttrNameSet) = do
23 let nonExistentAttributeNames = A.attributeNamesNotContained unselectedAttrNameSet (A.attributeNameSet attrs)
24 if not $ S.null nonExistentAttributeNames then
25 Left $ AttributeNamesMismatchError nonExistentAttributeNames
27 return $ A.attributesForNames (A.nonMatchingAttributeNameSet unselectedAttrNameSet (A.attributeNameSet attrs)) attrs
28projectionAttributesForAttributeNames attrs (UnionAttributeNames namesA namesB) = do
29 attrsA <- projectionAttributesForAttributeNames attrs namesA
30 attrsB <- projectionAttributesForAttributeNames attrs namesB
31 pure (A.union attrsA attrsB)
32projectionAttributesForAttributeNames attrs (IntersectAttributeNames namesA namesB) = A.intersection <$> projectionAttributesForAttributeNames attrs namesA <*> projectionAttributesForAttributeNames attrs namesB
34invertAttributeNames :: AttributeNames -> AttributeNames
35invertAttributeNames (AttributeNames names) = InvertedAttributeNames names
36invertAttributeNames (InvertedAttributeNames names) = AttributeNames names
37invertAttributeNames (UnionAttributeNames namesA namesB) = IntersectAttributeNames (invertAttributeNames namesA) (invertAttributeNames namesB)
38invertAttributeNames (IntersectAttributeNames namesA namesB) = UnionAttributeNames (invertAttributeNames namesA) (invertAttributeNames namesB)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list