on 5cc025d help sign in
project-m36/RelationType.hs
30 lines 1.1 kB history raw
1module RelationType where
2import qualified Data.Map as M
3import qualified Data.HashSet as HS
4import qualified Data.Hashable as Hash
6data Atom = StringAtom String |
7 IntAtom Int |
8 RelationAtom Relation deriving (Show, Eq)
10data AtomType = StringAtomType |
11 IntAtomType |
12 RelationAtomType Attributes deriving (Eq, Show)
14type AttributeName = String
15data Attribute = Attribute AttributeName AtomType deriving (Eq, Show)
17type Attributes = M.Map AttributeName Attribute --attributes keys by attribute name for ease of access
19type RelationTupleSet = HS.HashSet RelationTuple
21instance Hash.Hashable RelationTuple where
22 hashWithSalt salt tup = Hash.hashWithSalt salt (show tup)
24data RelationTuple = RelationTuple (M.Map AttributeName Atom) deriving (Eq, Show)
26data Relation = Relation Attributes RelationTupleSet deriving (Show, Eq)
27data RelationCardinality = Uncountable | Countable Int deriving (Eq, Show)
28data RelationSizeInfinite = RelationSizeInfinite
30data RelationalError = RelationalError Int String deriving (Show,Eq)