module ProjectM36.DatabaseContext where
import ProjectM36.Base
import qualified Data.Map as M
import qualified Data.HashSet as HS
import ProjectM36.DataTypes.Basic
import ProjectM36.AtomFunctions.Basic
import ProjectM36.DatabaseContextFunction
import ProjectM36.Relation
empty :: DatabaseContext
empty = DatabaseContext { inclusionDependencies = M.empty,
relationVariables = M.empty,
notifications = M.empty,
atomFunctions = HS.empty,
dbcFunctions = HS.empty,
typeConstructorMapping = [] }
databaseContextAsDatabaseContextExpr :: DatabaseContext -> DatabaseContextExpr
databaseContextAsDatabaseContextExpr context = MultipleExpr $ relVarsExprs ++ incDepsExprs ++ funcsExprs
where
relVarsExprs = map (\(name, rel) -> Assign name (ExistingRelation rel)) (M.toList (relationVariables context))
incDepsExprs :: [DatabaseContextExpr]
incDepsExprs = map (uncurry AddInclusionDependency) (M.toList (inclusionDependencies context))
funcsExprs = []
basicDatabaseContext :: DatabaseContext
basicDatabaseContext = DatabaseContext { inclusionDependencies = M.empty,
relationVariables = M.fromList [("true", relationTrue),
("false", relationFalse)],
atomFunctions = basicAtomFunctions,
dbcFunctions = basicDatabaseContextFunctions,
notifications = M.empty,
typeConstructorMapping = basicTypeConstructorMapping
}