2module TutorialD.Interpreter.InformationOperator where
5import TutorialD.Interpreter.Base
6-- older versions of stack fail to
7#if !defined(VERSION_project_m36)
8# warning Failed to discover proper version from cabal_macros.h
9# define VERSION_project_m36 "<unknown>"
12-- this module provides information about the current interpreter
14data InformationOperator = HelpOperator |
18infoOpP :: Parser InformationOperator
19infoOpP = helpOpP <|> getVersionP
21helpOpP :: Parser InformationOperator
22helpOpP = reserved ":help" >> pure HelpOperator
24getVersionP :: Parser InformationOperator
25getVersionP = reserved ":version" >> pure GetVersionOperator
27evalInformationOperator :: InformationOperator -> Either Text Text
28evalInformationOperator GetVersionOperator = Right ("tutd " `append` VERSION_project_m36)
29-- display generic help
30evalInformationOperator HelpOperator = Right $ intercalate "\n" help
35 ":showexpr relation{name Text, address Text}{tuple{name \"Steve\", address \"Main St.\"}}",
36 "address := relation{tuple{name \"Steve\", address \"Main St.\"}}",
37 ":showexpr true join false = false",
38 "Relational Operators:",
39 ":showexpr relation{a Int, b Text}{} -- relation creation",
40 ":showexpr relation{tuple{c t}} -- relation creation",
41 ":showexpr relation{tuple{a 4, b 4}}{a} -- projection",
42 ":showexpr relation{tuple{a 5}} rename {a as num} -- rename",
43 ":showexpr relation{tuple{d 10}} where d=10 or d=5 -- restriction",
44 ":showexpr relation{tuple{d 10}} : {e:=add(@d,5)} -- extension",
45 "Database Context Operators:",
46 "animal := relation{tuple{name \"octopus\", legs_count 8}} -- assignment",
47 "insert animal relation{tuple{name \"cat\", legs_count 4}} -- insertion",
48 "car :: {model Text, make Text, year Int} -- definition",
49 "undefine car -- undefine",
50 "delete animal where legs_count=4 -- deletion",
51 "update animal where name=\"octopus\" (name:=\"Mr. Octopus\") -- updating",
52 "employee:=relation{id Int, name Text, age Int}{}; key emp_unique_id {id} employee --uniqueness constraint",
53 "constraint age_gt_zero (employee{age} where ^lt(@age,0)){} equals false -- constraint",
54 "notify teenager_added employee where ^lt(@age,20) and ^gte(@age,13) employee{age} where ^lt(@age,20) and ^gte(@age,13) -- change notification",
56 ":jumphead <head_name> - change the current database context to point to a current head",
57 ":jump <transaction_id> - change the current database context to that of a past transaction",
58 ":commit - push the current context into the current head and make it immutable",
59 ":rollback - discard any changes made in the current context",
60 ":showgraph - display the transaction graph",
61 "View more documentation at: https://github.com/agentm/project-m36/blob/master/docs/tutd_tutorial.markdown"
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