@@ -1,4 +1,4 @@
1−{-# LANGUAGE ExistentialQuantification,DeriveGeneric,DeriveAnyClass,FlexibleInstances,OverloadedStrings, DeriveTraversable #-}
1+{-# LANGUAGE ExistentialQuantification,DeriveGeneric,DeriveAnyClass,FlexibleInstances,OverloadedStrings, DeriveTraversable, DerivingVia #-}
2{-# OPTIONS_GHC -fno-warn-orphans #-}
2{-# OPTIONS_GHC -fno-warn-orphans #-}
4module ProjectM36.Base where
4module ProjectM36.Base where
@@ -18,15 +18,15 @@ import GHC.Stack
18import qualified Data.Vector as V
18import qualified Data.Vector as V
19import qualified Data.List as L
19import qualified Data.List as L
20import Data.Text (Text,unpack)
20import Data.Text (Text,unpack)
22import Data.Vector.Binary()
21import Data.Vector.Binary()
23import Data.Time.Clock
22import Data.Time.Clock
24−import Data.Time.Clock.POSIX
25−import Data.Time.Calendar (Day,toGregorian,fromGregorian)
26import Data.Hashable.Time ()
23import Data.Hashable.Time ()
24+import Data.Time.Calendar (Day)
27import Data.Typeable
25import Data.Typeable
28import Data.ByteString (ByteString)
26import Data.ByteString (ByteString)
29import qualified Data.List.NonEmpty as NE
27import qualified Data.List.NonEmpty as NE
30type StringType = Text
30type StringType = Text
32-- | Database atoms are the smallest, undecomposable units of a tuple. Common examples are integers, text, or unique identity keys.
32-- | Database atoms are the smallest, undecomposable units of a tuple. Common examples are integers, text, or unique identity keys.
@@ -40,7 +40,7 @@ data Atom = IntegerAtom Integer |
40 BoolAtom Bool |
40 BoolAtom Bool |
41 RelationAtom Relation |
41 RelationAtom Relation |
42 ConstructedAtom DataConstructorName AtomType [Atom]
42 ConstructedAtom DataConstructorName AtomType [Atom]
43− deriving (Eq, Show, Binary, Typeable, NFData, Generic)
43+ deriving (Eq, Show, Typeable, NFData, Generic)
45instance Hashable Atom where
45instance Hashable Atom where
46 hashWithSalt salt (ConstructedAtom dConsName _ atoms) = salt `hashWithSalt` atoms
46 hashWithSalt salt (ConstructedAtom dConsName _ atoms) = salt `hashWithSalt` atoms
@@ -55,16 +55,6 @@ instance Hashable Atom where
55 hashWithSalt salt (BoolAtom b) = salt `hashWithSalt` b
55 hashWithSalt salt (BoolAtom b) = salt `hashWithSalt` b
56 hashWithSalt salt (RelationAtom r) = salt `hashWithSalt` r
56 hashWithSalt salt (RelationAtom r) = salt `hashWithSalt` r
58−instance Binary UTCTime where
59− put utc = put $ toRational (utcTimeToPOSIXSeconds utc)
60− get = posixSecondsToUTCTime . fromRational <$> (get :: Get Rational)
62−instance Binary Day where
63− put day = put $ toGregorian day
65− (y,m,d) <- get :: Get (Integer, Int, Int)
66− return (fromGregorian y m d)
68-- I suspect the definition of ConstructedAtomType with its name alone is insufficient to disambiguate the cases; for example, one could create a type named X, remove a type named X, and re-add it using different constructors. However, as long as requests are served from only one DatabaseContext at-a-time, the type name is unambiguous. This will become a problem for time-travel, however.
58-- I suspect the definition of ConstructedAtomType with its name alone is insufficient to disambiguate the cases; for example, one could create a type named X, remove a type named X, and re-add it using different constructors. However, as long as requests are served from only one DatabaseContext at-a-time, the type name is unambiguous. This will become a problem for time-travel, however.
69-- | The AtomType uniquely identifies the type of a atom.
59-- | The AtomType uniquely identifies the type of a atom.
70data AtomType = IntAtomType |
60data AtomType = IntAtomType |
@@ -79,7 +69,7 @@ data AtomType = IntAtomType |
79 ConstructedAtomType TypeConstructorName TypeVarMap |
69 ConstructedAtomType TypeConstructorName TypeVarMap |
80 TypeVariableType TypeVarName
70 TypeVariableType TypeVarName
81 --wildcard used in Atom Functions and tuples for data constructors which don't provide all arguments to the type constructor
71 --wildcard used in Atom Functions and tuples for data constructors which don't provide all arguments to the type constructor
82− deriving (Eq, NFData, Generic, Binary, Show)
72+ deriving (Eq, NFData, Generic, Show)
84instance Ord AtomType where
74instance Ord AtomType where
85 compare = undefined
75 compare = undefined
@@ -98,7 +88,7 @@ isRelationAtomType _ = False
98type AttributeName = StringType
88type AttributeName = StringType
100-- | A relation's type is composed of attribute names and types.
90-- | A relation's type is composed of attribute names and types.
101−data Attribute = Attribute AttributeName AtomType deriving (Eq, Show, Generic, NFData, Binary)
91+data Attribute = Attribute AttributeName AtomType deriving (Eq, Show, Generic, NFData)
103instance Hashable Attribute where
93instance Hashable Attribute where
104 hashWithSalt salt (Attribute attrName _) = hashWithSalt salt attrName
94 hashWithSalt salt (Attribute attrName _) = hashWithSalt salt attrName
@@ -116,10 +106,7 @@ sortedAttributesIndices :: Attributes -> [(Int, Attribute)]
116sortedAttributesIndices attrs = L.sortBy (\(_, Attribute name1 _) (_,Attribute name2 _) -> compare name1 name2) $ V.toList (V.indexed attrs)
106sortedAttributesIndices attrs = L.sortBy (\(_, Attribute name1 _) (_,Attribute name2 _) -> compare name1 name2) $ V.toList (V.indexed attrs)
118-- | The relation's tuple set is the body of the relation.
108-- | The relation's tuple set is the body of the relation.
119−newtype RelationTupleSet = RelationTupleSet { asList :: [RelationTuple] } deriving (Hashable, Show, Generic, Binary)
109+newtype RelationTupleSet = RelationTupleSet { asList :: [RelationTuple] } deriving (Hashable, Show, Generic)
121−instance Read Relation where
122− readsPrec = error "relation read not supported"
124instance Eq RelationTupleSet where
111instance Eq RelationTupleSet where
125 set1 == set2 = hset set1 == hset set2
112 set1 == set2 = hset set1 == hset set2
@@ -146,8 +133,6 @@ instance Hashable RelationTuple where
146-- | A tuple is a set of attributes mapped to their 'Atom' values.
133-- | A tuple is a set of attributes mapped to their 'Atom' values.
147data RelationTuple = RelationTuple Attributes (V.Vector Atom) deriving (Show, Generic)
134data RelationTuple = RelationTuple Attributes (V.Vector Atom) deriving (Show, Generic)
149−instance Binary RelationTuple
151instance Eq RelationTuple where
136instance Eq RelationTuple where
152 (==) tuple1@(RelationTuple attrs1 _) tuple2@(RelationTuple attrs2 _) = attributesEqual attrs1 attrs2 && atomsEqual
137 (==) tuple1@(RelationTuple attrs1 _) tuple2@(RelationTuple attrs2 _) = attributesEqual attrs1 attrs2 && atomsEqual
@@ -158,7 +143,6 @@ instance Eq RelationTuple where
159instance NFData RelationTuple where rnf = genericRnf
144instance NFData RelationTuple where rnf = genericRnf
162data Relation = Relation Attributes RelationTupleSet deriving (Show, Generic,Typeable)
146data Relation = Relation Attributes RelationTupleSet deriving (Show, Generic,Typeable)
164instance Eq Relation where
148instance Eq Relation where
@@ -173,8 +157,6 @@ instance Hashable Relation where
174 sortedAttrs = map snd (sortedAttributesIndices attrs)
158 sortedAttrs = map snd (sortedAttributesIndices attrs)
176−instance Binary Relation
178-- | Used to represent the number of tuples in a relation.
160-- | Used to represent the number of tuples in a relation.
179data RelationCardinality = Countable | Finite Int deriving (Eq, Show, Generic, Ord)
161data RelationCardinality = Countable | Finite Int deriving (Eq, Show, Generic, Ord)
@@ -221,15 +203,11 @@ data RelationalExprBase a =
221 With [(WithNameExprBase a, RelationalExprBase a)] (RelationalExprBase a)
203 With [(WithNameExprBase a, RelationalExprBase a)] (RelationalExprBase a)
222 deriving (Show, Eq, Generic, NFData, Foldable, Functor, Traversable)
204 deriving (Show, Eq, Generic, NFData, Foldable, Functor, Traversable)
224−instance Binary RelationalExpr
226data WithNameExprBase a = WithNameExpr RelVarName a
206data WithNameExprBase a = WithNameExpr RelVarName a
227 deriving (Show, Eq, Generic, NFData, Foldable, Functor, Traversable)
207 deriving (Show, Eq, Generic, NFData, Foldable, Functor, Traversable)
229type WithNameExpr = WithNameExprBase ()
209type WithNameExpr = WithNameExprBase ()
231−instance Binary WithNameExpr
233type GraphRefWithNameExpr = WithNameExprBase GraphRefTransactionMarker
211type GraphRefWithNameExpr = WithNameExprBase GraphRefTransactionMarker
235type NotificationName = StringType
213type NotificationName = StringType
@@ -241,14 +219,14 @@ data Notification = Notification {
241 reportOldExpr :: RelationalExpr, --run the expression in the pre-change context
219 reportOldExpr :: RelationalExpr, --run the expression in the pre-change context
242 reportNewExpr :: RelationalExpr --run the expression in the post-change context
220 reportNewExpr :: RelationalExpr --run the expression in the post-change context
244− deriving (Show, Eq, Binary, Generic, NFData)
222+ deriving (Show, Eq, Generic, NFData)
246type TypeVarName = StringType
224type TypeVarName = StringType
248-- | Metadata definition for type constructors such as @data Either a b@.
226-- | Metadata definition for type constructors such as @data Either a b@.
249data TypeConstructorDef = ADTypeConstructorDef TypeConstructorName [TypeVarName] |
227data TypeConstructorDef = ADTypeConstructorDef TypeConstructorName [TypeVarName] |
250 PrimitiveTypeConstructorDef TypeConstructorName AtomType
228 PrimitiveTypeConstructorDef TypeConstructorName AtomType
251− deriving (Show, Generic, Binary, Eq, NFData)
229+ deriving (Show, Generic, Eq, NFData)
253-- | Found in data constructors and type declarations: Left (Either Int Text) | Right Int
231-- | Found in data constructors and type declarations: Left (Either Int Text) | Right Int
254type TypeConstructor = TypeConstructorBase ()
232type TypeConstructor = TypeConstructorBase ()
@@ -256,7 +234,7 @@ data TypeConstructorBase a = ADTypeConstructor TypeConstructorName [TypeConstruc
256 PrimitiveTypeConstructor TypeConstructorName AtomType |
234 PrimitiveTypeConstructor TypeConstructorName AtomType |
257 RelationAtomTypeConstructor [AttributeExprBase a] |
235 RelationAtomTypeConstructor [AttributeExprBase a] |
258 TypeVariable TypeVarName
236 TypeVariable TypeVarName
259− deriving (Show, Generic, Binary, Eq, NFData)
237+ deriving (Show, Generic, Eq, NFData)
261type TypeConstructorMapping = [(TypeConstructorDef, DataConstructorDefs)]
239type TypeConstructorMapping = [(TypeConstructorDef, DataConstructorDefs)]
@@ -266,20 +244,20 @@ type DataConstructorName = StringType
266type AtomTypeName = StringType
244type AtomTypeName = StringType
268-- | Used to define a data constructor in a type constructor context such as @Left a | Right b@
246-- | Used to define a data constructor in a type constructor context such as @Left a | Right b@
269−data DataConstructorDef = DataConstructorDef DataConstructorName [DataConstructorDefArg] deriving (Eq, Show, Binary, Generic, NFData)
247+data DataConstructorDef = DataConstructorDef DataConstructorName [DataConstructorDefArg] deriving (Eq, Show, Generic, NFData)
271type DataConstructorDefs = [DataConstructorDef]
249type DataConstructorDefs = [DataConstructorDef]
273data DataConstructorDefArg = DataConstructorDefTypeConstructorArg TypeConstructor |
251data DataConstructorDefArg = DataConstructorDefTypeConstructorArg TypeConstructor |
274 DataConstructorDefTypeVarNameArg TypeVarName
252 DataConstructorDefTypeVarNameArg TypeVarName
275− deriving (Show, Generic, Binary, Eq, NFData)
253+ deriving (Show, Generic, Eq, NFData)
277type InclusionDependencies = M.Map IncDepName InclusionDependency
255type InclusionDependencies = M.Map IncDepName InclusionDependency
278type RelationVariables = M.Map RelVarName GraphRefRelationalExpr
256type RelationVariables = M.Map RelVarName GraphRefRelationalExpr
280data GraphRefTransactionMarker = TransactionMarker TransactionId |
258data GraphRefTransactionMarker = TransactionMarker TransactionId |
281 UncommittedContextMarker
259 UncommittedContextMarker
282− deriving (Eq, Show, Binary, Generic, NFData, Ord)
260+ deriving (Eq, Show, Generic, NFData, Ord)
284-- a fundamental relational expr to which other relational expressions compile
262-- a fundamental relational expr to which other relational expressions compile
285type GraphRefRelationalExpr = RelationalExprBase GraphRefTransactionMarker
263type GraphRefRelationalExpr = RelationalExprBase GraphRefTransactionMarker
@@ -290,17 +268,18 @@ type Subschemas = M.Map SchemaName Schema
291-- | Every transaction has one concrete database context and any number of isomorphic subschemas.
269-- | Every transaction has one concrete database context and any number of isomorphic subschemas.
292data Schemas = Schemas DatabaseContext Subschemas
270data Schemas = Schemas DatabaseContext Subschemas
294-- | The DatabaseContext is a snapshot of a database's evolving state and contains everything a database client can change over time.
273-- | The DatabaseContext is a snapshot of a database's evolving state and contains everything a database client can change over time.
295-- I spent some time thinking about whether the VirtualDatabaseContext/Schema and DatabaseContext data constructors should be the same constructor, but that would allow relation variables to be created in a "virtual" context which would appear to defeat the isomorphisms of the contexts. It should be possible to switch to an alternative schema to view the same equivalent information without information loss. However, allowing all contexts to reference another context while maintaining its own relation variables, new types, etc. could be interesting from a security perspective. For example, if a user creates a new relvar in a virtual context, then does it necessarily appear in all linked contexts? After deliberation, I think the relvar should appear in *all* linked contexts to retain the isomorphic properties, even when the isomorphism is for a subset of the context. This hints that the IsoMorphs should allow for "fall-through"; that is, when a relvar is not defined in the virtual context (for morphing), then the lookup should fall through to the underlying context.
274-- I spent some time thinking about whether the VirtualDatabaseContext/Schema and DatabaseContext data constructors should be the same constructor, but that would allow relation variables to be created in a "virtual" context which would appear to defeat the isomorphisms of the contexts. It should be possible to switch to an alternative schema to view the same equivalent information without information loss. However, allowing all contexts to reference another context while maintaining its own relation variables, new types, etc. could be interesting from a security perspective. For example, if a user creates a new relvar in a virtual context, then does it necessarily appear in all linked contexts? After deliberation, I think the relvar should appear in *all* linked contexts to retain the isomorphic properties, even when the isomorphism is for a subset of the context. This hints that the IsoMorphs should allow for "fall-through"; that is, when a relvar is not defined in the virtual context (for morphing), then the lookup should fall through to the underlying context.
296newtype Schema = Schema SchemaIsomorphs
275newtype Schema = Schema SchemaIsomorphs
297− deriving (Generic, Binary)
276+ deriving (Generic)
299data SchemaIsomorph = IsoRestrict RelVarName RestrictionPredicateExpr (RelVarName, RelVarName) |
278data SchemaIsomorph = IsoRestrict RelVarName RestrictionPredicateExpr (RelVarName, RelVarName) |
300 IsoRename RelVarName RelVarName |
279 IsoRename RelVarName RelVarName |
301 IsoUnion (RelVarName, RelVarName) RestrictionPredicateExpr RelVarName --maps two relvars to one relvar
280 IsoUnion (RelVarName, RelVarName) RestrictionPredicateExpr RelVarName --maps two relvars to one relvar
302 -- IsoTypeConstructor in morphAttrExpr
281 -- IsoTypeConstructor in morphAttrExpr
303− deriving (Generic, Binary, Show)
282+ deriving (Generic, Show)
305type SchemaIsomorphs = [SchemaIsomorph]
284type SchemaIsomorphs = [SchemaIsomorph]
@@ -318,8 +297,6 @@ type IncDepName = StringType
318-- | Inclusion dependencies represent every possible database constraint. Constraints enforce specific, arbitrarily-complex rules to which the database context's relation variables must adhere unconditionally.
297-- | Inclusion dependencies represent every possible database constraint. Constraints enforce specific, arbitrarily-complex rules to which the database context's relation variables must adhere unconditionally.
319data InclusionDependency = InclusionDependency RelationalExpr RelationalExpr deriving (Show, Eq, Generic, NFData)
298data InclusionDependency = InclusionDependency RelationalExpr RelationalExpr deriving (Show, Eq, Generic, NFData)
321−instance Binary InclusionDependency
323type AttributeNameAtomExprMap = M.Map AttributeName AtomExpr
300type AttributeNameAtomExprMap = M.Map AttributeName AtomExpr
325--used for returning information about individual expressions
302--used for returning information about individual expressions
@@ -329,8 +306,6 @@ type DatabaseContextExpr = DatabaseContextExprBase ()
330type GraphRefDatabaseContextExpr = DatabaseContextExprBase GraphRefTransactionMarker
307type GraphRefDatabaseContextExpr = DatabaseContextExprBase GraphRefTransactionMarker
332−instance Binary GraphRefDatabaseContextExpr
334-- | Database context expressions modify the database context.
309-- | Database context expressions modify the database context.
335data DatabaseContextExprBase a =
310data DatabaseContextExprBase a =
336 NoOperation |
311 NoOperation |
@@ -360,8 +335,6 @@ data DatabaseContextExprBase a =
360 MultipleExpr [DatabaseContextExprBase a]
335 MultipleExpr [DatabaseContextExprBase a]
361 deriving (Show, Eq, Generic)
336 deriving (Show, Eq, Generic)
363−instance Binary DatabaseContextExpr
365type ObjModuleName = StringType
338type ObjModuleName = StringType
366type ObjFunctionName = StringType
339type ObjFunctionName = StringType
367type Range = (Int,Int)
340type Range = (Int,Int)
@@ -372,7 +345,7 @@ data DatabaseContextIOExprBase a =
372 AddDatabaseContextFunction DatabaseContextFunctionName [TypeConstructor] DatabaseContextFunctionBodyScript |
345 AddDatabaseContextFunction DatabaseContextFunctionName [TypeConstructor] DatabaseContextFunctionBodyScript |
373 LoadDatabaseContextFunctions ObjModuleName ObjFunctionName FilePath |
346 LoadDatabaseContextFunctions ObjModuleName ObjFunctionName FilePath |
374 CreateArbitraryRelation RelVarName [AttributeExprBase a] Range
347 CreateArbitraryRelation RelVarName [AttributeExprBase a] Range
375− deriving (Show, Eq, Generic, Binary)
348+ deriving (Show, Eq, Generic)
377type GraphRefDatabaseContextIOExpr = DatabaseContextIOExprBase GraphRefTransactionMarker
350type GraphRefDatabaseContextIOExpr = DatabaseContextIOExprBase GraphRefTransactionMarker
@@ -393,8 +366,6 @@ data RestrictionPredicateExprBase a =
393 AttributeEqualityPredicate AttributeName (AtomExprBase a) -- relationalexpr must result in relation with single tuple
366 AttributeEqualityPredicate AttributeName (AtomExprBase a) -- relationalexpr must result in relation with single tuple
394 deriving (Show, Eq, Generic, NFData, Foldable, Functor, Traversable)
367 deriving (Show, Eq, Generic, NFData, Foldable, Functor, Traversable)
396−instance Binary RestrictionPredicateExpr
398-- child + parent links
369-- child + parent links
399-- | 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.
370-- | 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.
400type HeadName = StringType
371type HeadName = StringType
@@ -403,6 +374,7 @@ type TransactionHeads = M.Map HeadName Transaction
404-- | The transaction graph is the global database's state which references every committed transaction.
375-- | The transaction graph is the global database's state which references every committed transaction.
405data TransactionGraph = TransactionGraph TransactionHeads (S.Set Transaction)
376data TransactionGraph = TransactionGraph TransactionHeads (S.Set Transaction)
407transactionHeadsForGraph :: TransactionGraph -> TransactionHeads
379transactionHeadsForGraph :: TransactionGraph -> TransactionHeads
408transactionHeadsForGraph (TransactionGraph hs _) = hs
380transactionHeadsForGraph (TransactionGraph hs _) = hs
@@ -425,12 +397,11 @@ data TransactionInfo = TransactionInfo TransactionId TransactionDiffs UTCTime |
425 deriving (Show, Generic)
397 deriving (Show, Generic)
428−instance Binary TransactionInfo
430-- | Every set of modifications made to the database are atomically committed to the transaction graph as a transaction.
400-- | Every set of modifications made to the database are atomically committed to the transaction graph as a transaction.
431type TransactionId = UUID
401type TransactionId = UUID
433data Transaction = Transaction TransactionId TransactionInfo Schemas
403data Transaction = Transaction TransactionId TransactionInfo Schemas
435-- | The disconnected transaction represents an in-progress workspace used by sessions before changes are committed. This is similar to git's "index". After a transaction is committed, it is "connected" in the transaction graph and can no longer be modified.
406-- | The disconnected transaction represents an in-progress workspace used by sessions before changes are committed. This is similar to git's "index". After a transaction is committed, it is "connected" in the transaction graph and can no longer be modified.
436data DisconnectedTransaction = DisconnectedTransaction TransactionId Schemas DirtyFlag
407data DisconnectedTransaction = DisconnectedTransaction TransactionId Schemas DirtyFlag
@@ -464,8 +435,6 @@ data AtomExprBase a = AttributeAtomExpr AttributeName |
464 ConstructedAtomExpr DataConstructorName [AtomExprBase a] a
435 ConstructedAtomExpr DataConstructorName [AtomExprBase a] a
465 deriving (Eq,Show,Generic, NFData, Foldable, Functor, Traversable)
436 deriving (Eq,Show,Generic, NFData, Foldable, Functor, Traversable)
467−instance Binary AtomExpr
469-- | Used in tuple creation when creating a relation.
438-- | Used in tuple creation when creating a relation.
470data ExtendTupleExprBase a = AttributeExtendTupleExpr AttributeName (AtomExprBase a)
439data ExtendTupleExprBase a = AttributeExtendTupleExpr AttributeName (AtomExprBase a)
471 deriving (Show, Eq, Generic, NFData, Foldable, Functor, Traversable)
440 deriving (Show, Eq, Generic, NFData, Foldable, Functor, Traversable)
@@ -473,8 +442,6 @@ data ExtendTupleExprBase a = AttributeExtendTupleExpr AttributeName (AtomExprBas
473type ExtendTupleExpr = ExtendTupleExprBase ()
442type ExtendTupleExpr = ExtendTupleExprBase ()
474type GraphRefExtendTupleExpr = ExtendTupleExprBase GraphRefTransactionMarker
443type GraphRefExtendTupleExpr = ExtendTupleExprBase GraphRefTransactionMarker
476−instance Binary ExtendTupleExpr
478--enumerates the list of functions available to be run as part of tuple expressions
445--enumerates the list of functions available to be run as part of tuple expressions
479type AtomFunctions = HS.HashSet AtomFunction
446type AtomFunctions = HS.HashSet AtomFunction
@@ -485,6 +452,7 @@ type AtomFunctionBodyScript = StringType
485type AtomFunctionBodyType = [Atom] -> Either AtomFunctionError Atom
452type AtomFunctionBodyType = [Atom] -> Either AtomFunctionError Atom
487data AtomFunctionBody = AtomFunctionBody (Maybe AtomFunctionBodyScript) AtomFunctionBodyType
454data AtomFunctionBody = AtomFunctionBody (Maybe AtomFunctionBodyScript) AtomFunctionBodyType
489instance NFData AtomFunctionBody where
457instance NFData AtomFunctionBody where
490 rnf (AtomFunctionBody mScript _) = rnf mScript
458 rnf (AtomFunctionBody mScript _) = rnf mScript
@@ -525,8 +493,6 @@ type AttributeNames = AttributeNamesBase ()
526type GraphRefAttributeNames = AttributeNamesBase GraphRefTransactionMarker
494type GraphRefAttributeNames = AttributeNamesBase GraphRefTransactionMarker
528−instance Binary AttributeNames
530-- | The persistence strategy is a global database option which represents how to persist the database in the filesystem, if at all.
496-- | The persistence strategy is a global database option which represents how to persist the database in the filesystem, if at all.
531data PersistenceStrategy = NoPersistence | -- ^ no filesystem persistence/memory-only database
497data PersistenceStrategy = NoPersistence | -- ^ no filesystem persistence/memory-only database
532 MinimalPersistence FilePath | -- ^ fsync off, not crash-safe
498 MinimalPersistence FilePath | -- ^ fsync off, not crash-safe
@@ -539,14 +505,12 @@ type GraphRefAttributeExpr = AttributeExprBase GraphRefTransactionMarker
539-- | Create attributes dynamically.
505-- | Create attributes dynamically.
540data AttributeExprBase a = AttributeAndTypeNameExpr AttributeName TypeConstructor a |
506data AttributeExprBase a = AttributeAndTypeNameExpr AttributeName TypeConstructor a |
541 NakedAttributeExpr Attribute
507 NakedAttributeExpr Attribute
542− deriving (Eq, Show, Generic, Binary, NFData, Foldable, Functor, Traversable)
508+ deriving (Eq, Show, Generic, NFData, Foldable, Functor, Traversable)
544-- | Dynamically create a tuple from attribute names and 'AtomExpr's.
510-- | Dynamically create a tuple from attribute names and 'AtomExpr's.
545newtype TupleExprBase a = TupleExpr (M.Map AttributeName (AtomExprBase a))
511newtype TupleExprBase a = TupleExpr (M.Map AttributeName (AtomExprBase a))
546 deriving (Eq, Show, Generic, NFData, Foldable, Functor, Traversable)
512 deriving (Eq, Show, Generic, NFData, Foldable, Functor, Traversable)
548−instance Binary TupleExpr
550type TupleExpr = TupleExprBase ()
514type TupleExpr = TupleExprBase ()
552type GraphRefTupleExpr = TupleExprBase GraphRefTransactionMarker
516type GraphRefTupleExpr = TupleExprBase GraphRefTransactionMarker
@@ -558,8 +522,6 @@ type GraphRefTupleExprs = TupleExprsBase GraphRefTransactionMarker
559type TupleExprs = TupleExprsBase ()
523type TupleExprs = TupleExprsBase ()
561−instance Binary TupleExprs
563data MergeStrategy =
525data MergeStrategy =
564 -- | After a union merge, the merge transaction is a result of union'ing relvars of the same name, introducing all uniquely-named relvars, union of constraints, union of atom functions, notifications, and types (unless the names and definitions collide, e.g. two types of the same name with different definitions)
526 -- | After a union merge, the merge transaction is a result of union'ing relvars of the same name, introducing all uniquely-named relvars, union of constraints, union of atom functions, notifications, and types (unless the names and definitions collide, e.g. two types of the same name with different definitions)
565 UnionMergeStrategy |
527 UnionMergeStrategy |
@@ -567,7 +529,7 @@ data MergeStrategy =
567 UnionPreferMergeStrategy HeadName |
529 UnionPreferMergeStrategy HeadName |
568 -- | Similar to the our/theirs merge strategy in git, the merge transaction's context is identical to that of the last transaction in the selected branch.
530 -- | Similar to the our/theirs merge strategy in git, the merge transaction's context is identical to that of the last transaction in the selected branch.
569 SelectedBranchMergeStrategy HeadName
531 SelectedBranchMergeStrategy HeadName
570− deriving (Eq, Show, Binary, Generic, NFData)
532+ deriving (Eq, Show, Generic, NFData)
572type DatabaseContextFunctionName = StringType
534type DatabaseContextFunctionName = StringType
@@ -635,20 +597,5 @@ unimplemented :: HasCallStack => a
635unimplemented = undefined
597unimplemented = undefined
637--for serializing GraphRefRelationalExpr as part of transaction serialization
599--for serializing GraphRefRelationalExpr as part of transaction serialization
638−instance Binary (TupleExprsBase GraphRefTransactionMarker)
640−instance Binary (TupleExprBase GraphRefTransactionMarker)
642−instance Binary GraphRefRelationalExpr
644−instance Binary (AtomExprBase GraphRefTransactionMarker)
646−instance Binary (AttributeNamesBase GraphRefTransactionMarker)
648−instance Binary (RestrictionPredicateExprBase GraphRefTransactionMarker)
650−instance Binary (ExtendTupleExprBase GraphRefTransactionMarker)
652−instance Binary GraphRefWithNameExpr