@@ -153,7 +153,8 @@ instance Eq RelationTuple where
153153
154154instance NFData RelationTuple where rnf = genericRnf
155155
156−data Relation = Relation Attributes RelationTupleSet deriving (Show, Generic,Typeable)
156+data Relation = Relation Attributes RelationTupleSet
157+ deriving (Show, Generic,Typeable)
157158
158159instance Eq Relation where
159160 Relation attrs1 tupSet1 == Relation attrs2 tupSet2 = attributesEqual attrs1 attrs2 && tupSet1 == tupSet2
@@ -188,6 +189,7 @@ data RelationalExprBase a =
188189 --in Tutorial D, relational variables pick up the type of the first relation assigned to them
189190 --relational variables should also be able to be explicitly-typed like in Haskell
190191 --- | Reference a relation variable by its name.
192+ -- this relies on access to the database context without altering the context, so should there be another type of expression? RODatabaseContextExpr? That would allow the RelationalExprs to be evaluated without ANY state needed
191193 RelationVariable RelVarName a |
192194 --- | Create a projection over attribute names. (Note that the 'AttributeNames' structure allows for the names to be inverted.)
193195 Project AttributeNames (RelationalExprBase a) |
@@ -210,10 +212,8 @@ data RelationalExprBase a =
210212 NotEquals (RelationalExprBase a) (RelationalExprBase a) |
211213 Extend (ExtendTupleExprBase a) (RelationalExprBase a)
212214 --Summarize :: AtomExpr -> AttributeName -> RelationalExpr -> RelationalExpr -> RelationalExpr -- a special case of Extend
213− deriving (Show, Eq, Generic)
215+ deriving (Show, Eq, Generic, NFData, Binary)
214216
215−instance Binary RelationalExpr
216−
217217type NotificationName = StringType
218218type Notifications = M.Map NotificationName Notification
219219
@@ -284,8 +284,10 @@ data DatabaseContext = DatabaseContext {
284284 relationVariables :: RelationVariables,
285285 atomFunctions :: AtomFunctions,
286286 notifications :: Notifications,
287− typeConstructorMapping :: TypeConstructorMapping
287+ typeConstructorMapping :: TypeConstructorMapping,
288+ thunks :: DatabaseContextExpr
288289 }
290+
289291
290292type IncDepName = StringType
291293
@@ -337,9 +339,7 @@ data RestrictionPredicateExprBase a =
337339 RelationalExprPredicate (RelationalExprBase a) | --type must be same as true and false relations (no attributes)
338340 AtomExprPredicate (AtomExprBase a) | --atom must evaluate to boolean
339341 AttributeEqualityPredicate AttributeName (AtomExprBase a) -- relationalexpr must result in relation with single tuple
340− deriving (Show, Eq, Generic)
341−
342−instance Binary RestrictionPredicateExpr
342+ deriving (Show, Eq, Generic, NFData, Binary)
343343
344344-- child + parent links
345345-- | A transaction graph's head name references the leaves of the transaction graph and can be used during session creation to indicate at which point in the graph commits should persist.
@@ -393,18 +393,14 @@ data AtomExprBase a = AttributeAtomExpr AttributeName |
393393 FunctionAtomExpr AtomFunctionName [AtomExprBase a] a |
394394 RelationAtomExpr (RelationalExprBase a) |
395395 ConstructedAtomExpr DataConstructorName [AtomExprBase a] a
396− deriving (Eq,Show,Generic)
396+ deriving (Eq, Show, Generic, NFData, Binary)
397397
398−instance Binary AtomExpr
399−
400398-- | Used in tuple creation when creating a relation.
401399data ExtendTupleExprBase a = AttributeExtendTupleExpr AttributeName (AtomExprBase a)
402− deriving (Show, Eq, Generic)
400+ deriving (Show, Eq, Generic, NFData, Binary)
403401
404402type ExtendTupleExpr = ExtendTupleExprBase ()
405403
406−instance Binary ExtendTupleExpr
407−
408404--enumerates the list of functions available to be run as part of tuple expressions
409405type AtomFunctions = HS.HashSet AtomFunction
410406
@@ -456,7 +452,7 @@ data AttributeNames = AttributeNames (S.Set AttributeName) |
456452 InvertedAttributeNames (S.Set AttributeName) |
457453 UnionAttributeNames AttributeNames AttributeNames |
458454 IntersectAttributeNames AttributeNames AttributeNames
459− deriving (Eq, Show, Generic)
455+ deriving (Eq, Show, Generic, NFData)
460456
461457instance Binary AttributeNames
462458
@@ -470,12 +466,10 @@ type AttributeExpr = AttributeExprBase ()
470466
471467data AttributeExprBase a = AttributeAndTypeNameExpr AttributeName TypeConstructor a |
472468 NakedAttributeExpr Attribute
473− deriving (Eq, Show, Generic, Binary)
469+ deriving (Eq, Show, Generic, Binary, NFData)
474470
475471data TupleExprBase a = TupleExpr (M.Map AttributeName (AtomExprBase a))
476− deriving (Eq, Show, Generic)
477−
478−instance Binary TupleExpr
472+ deriving (Eq, Show, Generic, NFData, Binary)
479473
480474type TupleExpr = TupleExprBase ()
481475