@@ -8,6 +8,7 @@ import ProjectM36.Error
88import ProjectM36.Atom
99import ProjectM36.Key
1010import ProjectM36.AtomFunction
11+import ProjectM36.DataTypes.Interval
1112import qualified ProjectM36.Attribute as A
1213import qualified Data.Map as M
1314import qualified Data.HashSet as HS
@@ -15,7 +16,6 @@ import qualified Data.Set as S
1516import Control.Monad.State hiding (join)
1617import Data.Maybe
1718import Data.Either
18−import Data.Typeable (cast)
1919
2020--relvar state is needed in evaluation of relational expression but only as read-only in order to extract current relvar values
2121evalRelationalExpr :: RelationalExpr -> DatabaseState (Either RelationalError Relation)
@@ -482,19 +482,9 @@ verifyAtomExprTypes _ context (RelationAtomExpr relationExpr) expectedType = do
482482 (Left err, _) -> Left err
483483 (Right relType, _) -> atomTypeVerify expectedType (RelationAtomType (attributes relType))
484484
485−--not safe to use without upfront type-checking
486−castRelation :: Atom -> Relation
487−castRelation (Atom atom) = case cast atom of
488− Just rel -> rel
489− Nothing -> error "castRelation failure"
490−
491−unsafeCast :: (Atomable a) => Atom -> a
492−unsafeCast (Atom atom) = case cast atom of
493− Just x -> x
494− Nothing -> error "unsafeCast failed"
495485
496486basicAtomFunctions :: AtomFunctions
497−basicAtomFunctions = HS.fromList [
487+basicAtomFunctions = HS.fromList $ [
498488 --match on any relation type
499489 AtomFunction { atomFuncName = "add",
500490 atomFuncType = [intAtomType, intAtomType, intAtomType],
@@ -529,7 +519,7 @@ basicAtomFunctions = HS.fromList [
529519 AtomFunction { atomFuncName = "not",
530520 atomFuncType = [boolAtomType, boolAtomType],
531521 atomFunc = boolAtomNot}
532− ]
522+ ] ++ intervalFunctions
533523
534524intAtomFuncLessThan :: Bool -> [Atom] -> Atom
535525intAtomFuncLessThan equality (iatom1:iatom2:_) = (\i1 i2 -> Atom $ ((unsafeCast i1)::Int) `op` unsafeCast i2) iatom1 iatom2