1module TutorialD.Interpreter.SchemaOperator where
3import Text.Megaparsec.Text
6import ProjectM36.IsomorphicSchema
7import ProjectM36.Session
8import ProjectM36.Client
10import TutorialD.Interpreter.RelationalExpr
11import TutorialD.Interpreter.Base
13data SchemaOperator = ModifySchemaExpr SchemaExpr |
14 SetCurrentSchema SchemaName
16schemaOperatorP :: Parser SchemaOperator
17schemaOperatorP = (ModifySchemaExpr <$> schemaExprP) <|>
20setCurrentSchemaP :: Parser SchemaOperator
23 SetCurrentSchema <$> identifier
25schemaExprP :: Parser SchemaExpr
26schemaExprP = addSubschemaIsoMorphP <|>
29addSubschemaP :: Parser SchemaExpr
31 reserved ":addsubschema"
32 AddSubschema <$> identifier
34addSubschemaIsoMorphP :: Parser SchemaExpr
35addSubschemaIsoMorphP = do
36 reserved ":addsubschemaisomorph"
37 AddSubschemaIsomorph <$> identifier <*> schemaIsomorphP
39schemaIsomorphP :: Parser SchemaIsomorph
40schemaIsomorphP = isoRestrictP <|> isoUnionP
42isoRestrictP :: Parser SchemaIsomorph
44 reserved "isorestrict"
46 relvarsOut <- isoRestrictOutRelVarsP
47 IsoRestrict <$> pure relVarIn <*> restrictionPredicateP <*> pure relvarsOut
49isoRestrictOutRelVarsP :: Parser (RelVarName, RelVarName)
50isoRestrictOutRelVarsP = (,) <$> qrelVarP <*> qrelVarP
52qrelVarP :: Parser RelVarName
53qrelVarP = quotedString
55isoUnionP :: Parser SchemaIsomorph
58 IsoUnion <$> isoUnionInRelVarsP <*> restrictionPredicateP <*> qrelVarP
60isoUnionInRelVarsP :: Parser (RelVarName, RelVarName)
61isoUnionInRelVarsP = (,) <$> qrelVarP <*> qrelVarP
63evalSchemaOperator :: SessionId -> Connection -> SchemaOperator -> IO (Maybe RelationalError)
64evalSchemaOperator sessionId conn (ModifySchemaExpr expr) = executeSchemaExpr sessionId conn expr
65evalSchemaOperator sessionId conn (SetCurrentSchema sname) = setCurrentSchemaName sessionId conn sname
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list