on master help sign in
replace unnecessary GADTs from Base.hs with hope of reducing compile time
commit56b0f2d5902090b0fbb297db887ee31c45e2e812 authorAgentM <agentm@themactionfaction.com> dateThu 21 Jul 2016, 15:19 (10 years ago) parentceb7f8c
1 file changed+25−25
ProjectM36/Base.hs+25−25
ProjectM36/Base.hs+25−25
@@ -1,4 +1,4 @@
1−{-# LANGUAGE ExistentialQuantification,BangPatterns,GADTs,DeriveGeneric,DeriveAnyClass #-}
1+{-# LANGUAGE ExistentialQuantification,BangPatterns,DeriveGeneric,DeriveAnyClass #-}
22{-# OPTIONS_GHC -fno-warn-orphans #-}
33module ProjectM36.Base where
44import qualified Data.Map as M
@@ -232,38 +232,38 @@ data RelationCardinality = Countable | Finite Int deriving (Eq, Show, Generic, O
232232type RelVarName = StringType
233233
234234-- | A relational expression represents query (read) operations on a database.
235−data RelationalExpr where
235+data RelationalExpr =
236236 --- | Create a relation from tuple expressions.
237− MakeRelationFromExprs :: Maybe [AttributeExpr] -> [TupleExpr] -> RelationalExpr
237+ MakeRelationFromExprs (Maybe [AttributeExpr]) [TupleExpr] |
238238 --- | Create and reference a relation from attributes and a tuple set.
239− MakeStaticRelation :: Attributes -> RelationTupleSet -> RelationalExpr
239+ MakeStaticRelation Attributes RelationTupleSet |
240240 --- | Reference an existing relation in Haskell-space.
241− ExistingRelation :: Relation -> RelationalExpr
241+ ExistingRelation Relation |
242242 --MakeFunctionalRelation (creates a relation from a tuple-generating function, potentially infinite)
243243 --in Tutorial D, relational variables pick up the type of the first relation assigned to them
244244 --relational variables should also be able to be explicitly-typed like in Haskell
245245 --- | Reference a relation variable by its name.
246− RelationVariable :: RelVarName -> RelationalExpr
246+ RelationVariable RelVarName |
247247 --- | Create a projection over attribute names. (Note that the 'AttributeNames' structure allows for the names to be inverted.)
248− Project :: AttributeNames -> RelationalExpr -> RelationalExpr
248+ Project AttributeNames RelationalExpr |
249249 --- | Create a union of two relational expressions. The expressions should have identical attributes.
250− Union :: RelationalExpr -> RelationalExpr -> RelationalExpr
250+ Union RelationalExpr RelationalExpr |
251251 --- | Create a join of two relational expressions. The join occurs on attributes which are identical. If the expressions have no overlapping attributes, the join becomes a cross-product of both tuple sets.
252− Join :: RelationalExpr -> RelationalExpr -> RelationalExpr
252+ Join RelationalExpr RelationalExpr |
253253 --- | Rename an attribute (first argument) to another (second argument).
254− Rename :: AttributeName -> AttributeName -> RelationalExpr -> RelationalExpr
254+ Rename AttributeName AttributeName RelationalExpr |
255255 --- | Return a relation containing all tuples of the first argument which do not appear in the second argument (minus).
256− Difference :: RelationalExpr -> RelationalExpr -> RelationalExpr
256+ Difference RelationalExpr RelationalExpr |
257257 --- | Create a sub-relation composed of the first argument's attributes which will become an attribute of the result expression. The unreferenced attributes are not altered in the result but duplicate tuples in the projection of the expression minus the attribute names are compressed into one. For more information, <https://github.com/agentm/project-m36/blob/master/docs/introduction_to_the_relational_algebra.markdown#group read the relational algebra tutorial.>
258− Group :: AttributeNames -> AttributeName -> RelationalExpr -> RelationalExpr
258+ Group AttributeNames AttributeName RelationalExpr |
259259 --- | Create an expression to unwrap a sub-relation contained within at an attribute's name. Note that this is not always an inverse of a group operation.
260− Ungroup :: AttributeName -> RelationalExpr -> RelationalExpr
260+ Ungroup AttributeName RelationalExpr |
261261 --- | Filter the tuples of the relational expression to only retain the tuples which evaluate against the restriction predicate to true.
262− Restrict :: RestrictionPredicateExpr -> RelationalExpr -> RelationalExpr
262+ Restrict RestrictionPredicateExpr RelationalExpr |
263263 --- | Returns the true relation iff
264− Equals :: RelationalExpr -> RelationalExpr -> RelationalExpr
265− NotEquals :: RelationalExpr -> RelationalExpr -> RelationalExpr
266− Extend :: ExtendTupleExpr -> RelationalExpr -> RelationalExpr
264+ Equals RelationalExpr RelationalExpr |
265+ NotEquals RelationalExpr RelationalExpr |
266+ Extend ExtendTupleExpr RelationalExpr
267267 --Summarize :: AtomExpr -> AttributeName -> RelationalExpr -> RelationalExpr -> RelationalExpr -- a special case of Extend
268268 deriving (Show, Eq, Generic, Binary)
269269
@@ -358,14 +358,14 @@ data DatabaseContextExpr =
358358type DatabaseState a = State DatabaseContext a
359359
360360-- | Restriction predicate are boolean algebra components which, when composed, indicate whether or not a tuple should be retained during a restriction (filtering) operation.
361−data RestrictionPredicateExpr where
362− TruePredicate :: RestrictionPredicateExpr
363− AndPredicate :: RestrictionPredicateExpr -> RestrictionPredicateExpr -> RestrictionPredicateExpr
364− OrPredicate :: RestrictionPredicateExpr -> RestrictionPredicateExpr -> RestrictionPredicateExpr
365− NotPredicate :: RestrictionPredicateExpr -> RestrictionPredicateExpr
366− RelationalExprPredicate :: RelationalExpr -> RestrictionPredicateExpr --type must be same as true and false relations (no attributes)
367− AtomExprPredicate :: AtomExpr -> RestrictionPredicateExpr --atom must evaluate to boolean
368− AttributeEqualityPredicate :: AttributeName -> AtomExpr -> RestrictionPredicateExpr -- relationalexpr must result in relation with single tuple
361+data RestrictionPredicateExpr =
362+ TruePredicate |
363+ AndPredicate RestrictionPredicateExpr RestrictionPredicateExpr |
364+ OrPredicate RestrictionPredicateExpr RestrictionPredicateExpr |
365+ NotPredicate RestrictionPredicateExpr |
366+ RelationalExprPredicate RelationalExpr | --type must be same as true and false relations (no attributes)
367+ AtomExprPredicate AtomExpr | --atom must evaluate to boolean
368+ AttributeEqualityPredicate AttributeName AtomExpr -- relationalexpr must result in relation with single tuple
369369 deriving (Show, Eq, Generic)
370370
371371instance Binary RestrictionPredicateExpr