@@ -1,4 +1,4 @@
1−{-# LANGUAGE GADTs #-}
1+{-# LANGUAGE GADTs,DeriveGeneric #-}
22module ProjectM36.Base where
33import qualified Data.Map as M
44import qualified Data.HashSet as HS
@@ -6,17 +6,23 @@ import qualified Data.Hashable as Hash
66import qualified Data.Set as S
77import Control.Monad.State hiding (join)
88import Data.UUID (UUID)
9+import Control.DeepSeq (NFData, rnf)
10+import Control.DeepSeq.Generics (genericRnf)
11+import GHC.Generics (Generic)
912
1013data Atom = StringAtom String |
1114 IntAtom Int |
12− RelationAtom Relation deriving (Show, Eq)
13−
15+ RelationAtom Relation deriving (Show, Eq, Generic)
16+
17+instance NFData Atom where rnf = genericRnf
1418
1519data AtomType = StringAtomType |
1620 IntAtomType |
17− RelationAtomType Attributes deriving (Eq, Show)
21+ RelationAtomType Attributes deriving (Eq, Show, Generic)
1822
19−atomTypeForAtom :: Atom -> AtomType
23+instance NFData AtomType where rnf = genericRnf
24+
25+atomTypeForAtom :: Atom -> AtomType
2026atomTypeForAtom (StringAtom _) = StringAtomType
2127atomTypeForAtom (IntAtom _) = IntAtomType
2228atomTypeForAtom (RelationAtom (Relation attributes _)) = RelationAtomType attributes
@@ -24,7 +30,9 @@ atomTypeForAtom (RelationAtom (Relation attributes _)) = RelationAtomType attrib
2430type AttributeName = String
2531type AtomName = String
2632
27−data Attribute = Attribute AttributeName AtomType deriving (Eq, Show)
33+data Attribute = Attribute AttributeName AtomType deriving (Eq, Show, Generic)
34+
35+instance NFData Attribute where rnf = genericRnf
2836
2937type Attributes = M.Map AttributeName Attribute --attributes keys by attribute name for ease of access
3038
@@ -32,11 +40,16 @@ type RelationTupleSet = HS.HashSet RelationTuple
3240
3341instance Hash.Hashable RelationTuple where
3442 hashWithSalt salt tup = Hash.hashWithSalt salt (show tup)
35−
36−data RelationTuple = RelationTuple (M.Map AttributeName Atom) deriving (Eq, Show)
43+
44+data RelationTuple = RelationTuple (M.Map AttributeName Atom) deriving (Eq, Show, Generic)
3745
38−data Relation = Relation Attributes RelationTupleSet deriving (Show, Eq)
39−data RelationCardinality = Uncountable | Countable Int deriving (Eq, Show)
46+instance NFData RelationTuple where rnf = genericRnf
47+
48+data Relation = Relation Attributes RelationTupleSet deriving (Show, Eq, Generic)
49+
50+instance NFData Relation where rnf = genericRnf
51+
52+data RelationCardinality = Uncountable | Countable Int deriving (Eq, Show, Generic)
4053data RelationSizeInfinite = RelationSizeInfinite
4154
4255data RelationalExpr where