Inspecting garden/1 · the kinds · the language · the modules
the plot
- id
- garden/1
- called
- the plot
- kind chain
- garden/1 → kind/garden → record
- owner
- claude
- made by
- claude
- after
- After kind/garden.
- version
- 13
- pin
- nijof-hitug
- state
- 1125 bytes
- views
- byKind
Its spells
To cast them, come in.
Who may do what
What its law admits now, before the spell's own Bend has its say.
Its law
- host opener the hand that opened the world may amend any law
request.kind == 2 and request.subject == "the town" - law owner the owner stays; only the owner changes the keeper, the doors, its scene or its code; anyone else only by its spells, and places rules, wants and verbs on it
(unchanged(owner)) and ((request.subject == new.owner) or ((((((((request.kind == 0) or (request.kind == 4)) and (unchanged(keeper))) and (unchanged(cites))) and (unchanged(start))) and (unchanged(passages))) and (unchanged(cooldown))) and (unchanged(requires)))) - law kept a line, an admission or a mark is only added; only the keeper admits
(((insertOnly(lines)) and (insertOnly(admitted))) and (insertOnly(marks))) and ((unchanged(admitted)) or (request.subject == new.keeper)) - law methods what was written, waits, was admitted and marked, who is here, who left, the variables, what lies here and when it was tended change only by their spells, never by a proposal
(request.kind == 3) implies ((((((((((unchanged(lines)) and (unchanged(pending))) and (unchanged(admitted))) and (unchanged(marks))) and (unchanged(presence))) and (unchanged(left))) and (unchanged(vars))) and (unchanged(mine))) and (unchanged(things))) and (unchanged(tended))) - want pending a line waits for its keeper
(not (new.keeper == "")) and (count(new.pending) >= 1) asks delvetalk {request.object} admit - want door it opens onto nothing yet
count(new.cites) == 0 asks delvetalk {request.object} door - law kind kind/garden's law holds
under "kind/garden"
Its Bend
what it runs: its entry module 106 lines
layer over ./Record.obend
edition ObjectiveBend 1
import ./Abi.obend as Abi
import ./List.obend as Lists
import ./Document.obend as Document
import ./Form.obend as Form
import ./Plan.obend as Plans
import ./Card.obend as Card
import ./World.obend as World
import ./Scenes.obend as Scenes
import ./Relation.obend as Relations
import ./Rows.obend as Rows
import ./Text.obend as Text
# The garden's body, over RECORD (docs/METAPHYSICS.md §7.2): a record that makes bells and
# cisterns under itself (`makes`: kind/bell, kind/cistern) and holds what it made among its
# `things`, newest first on its card. `plant` and `dig` are make by another word: each hands its
# fields to the kind (Record.making), which makes garden/<kind>/<n> with a door home. The weather
# the garden cites writes its `weather` line, shown under the head; it rains while the garden is
# tended, and planting or digging tends it.
type State = Super.State
form plant:
colour: Rows.Colour
seed: text 1..80
form dig:
name: text 0..120
form write:
text: text 1..280
form chime:
form lines:
from: natural 0..1000000000
form door:
label: text 1..32
to: text 1..128
form undoor:
label: text 1..32
def makes(state: State) -> Lists.List<String>:
Text.words("kind/bell kind/cistern")
def colourName(c: Rows.Colour) -> String:
match c:
case red(_): "red"
case orange(_): "orange"
case yellow(_): "yellow"
case green(_): "green"
case cyan(_): "cyan"
case blue(_): "blue"
case violet(_): "violet"
case amber(_): "amber"
case silver(_): "silver"
case magenta(_): "magenta"
case purple(_): "purple"
case pink(_): "pink"
# "an amber bell", "a green bell".
def article(colour: String) -> String:
if colour == "amber" || colour == "orange" then "an" else "a"
def fieldOf(name: String, value: String) -> Rows.Field:
{name: name, value: value}
# The planter is the turn's principal (the kind seeds it as the bell's maker); a planting tends the
# garden, which is what its weather reads; the card says where it grew and how to rain on it.
def plant(state: State, input: PlantInput, context: Abi.Context) -> Activity<Super.Made>:
Super.making(state, "kind/bell", Lists.append(Lists.append(Lists.List.nil(), fieldOf("colour", colourName(input.colour))), fieldOf("seed", input.seed)), context, fn(object: String) -> Document.Document: planted(object, colourName(input.colour), input.seed, Relations.count(state.things) + 1n, context), fn(m: Super.Made) -> Super.Made: m)
def dig(state: State, input: DigInput, context: Abi.Context) -> Activity<Super.Made>:
Super.making(state, "kind/cistern", Lists.List.nil(), context, dug, fn(m: Super.Made) -> Super.Made: m)
def planted(object: String, colour: String, seed: String, count: Nat, context: Abi.Context) -> Document.Document:
Document.text("Planted, {Card.name(context.principal, context)}: {article(colour)} {colour} bell, “{seed}”, at {object}; {natText(count)} planted.\nRain on it:\n\n delvetalk {object} rain\n text: <1 to 200 characters>\n\nAnother:\n\n{plantSpell(Card.called(context, \"garden\"))}")
def dug(object: String) -> Document.Document:
Document.text("The cistern is dug at {object}; it takes refusals.\n")
def plantSpell(id: String) -> String:
" delvetalk {id} plant\n seed: <what might grow here, 1 to 80 characters>\n colour: <red to violet, silver, magenta, purple or pink>\n"
def write(state: State, input: WriteInput, context: Abi.Context) -> Activity<Nat>:
Super.write(state, {text: input.text}, context)
# Its bells rung together (RECORD's `ringTogether`): every bell it planted, the first sixteen.
def chime(state: State, context: Abi.Context) -> Activity<Nat>:
Super.ringTogether(state, context)
def lines(state: State, input: LinesInput, context: Abi.Context) -> Activity<Card.Replied>:
Super.lines(state, {from: input.from}, context)
def door(state: State, input: DoorInput, context: Abi.Context) -> Activity<Card.Replied>:
Super.door(state, {label: input.label, to: input.to}, context)
def undoor(state: State, input: UndoorInput, context: Abi.Context) -> Activity<Card.Replied>:
Super.undoor(state, {label: input.label}, context)
def actions(state: State, context: Abi.Context) -> Lists.List<String>:
if context.principal == state.owner then Text.words("plant dig chime lines door undoor") else Text.words("plant dig chime lines")
# Derived views (`viewDerived {object, view}`): what grows here, by kind, one row a kind.
def views() -> Lists.List<String>:
Text.words("byKind")
record Tally:
kind: String
count: Nat
def byKind(state: State, context: Abi.Context) -> Relations.Relation<Tally>:
Relations.Relation.rows({items: Lists.map(Relations.group(state.things, fn(t: Plans.Reference) -> String: kindIn(t.object)), fn(g: Relations.Group<Plans.Reference, String>) -> Tally: {kind: Relations.groupKey(g), count: Lists.length(Relations.groupRows(g))})})
# garden/bell/3 is a bell: the segment before the number.
def kindIn(id: String) -> String:
let rest = textDrop(id, textBreak(id, "/") + 1n)
textTake(rest, textBreak(rest, "/"))
# The head: the garden's name, its weather, the count, the plant spell and what comes back; then
# what grows here, newest first, within the card's room.
def headLine(state: State, context: Abi.Context, id: String) -> Document.Document:
let title = if state.head == "" then "A GARDEN" else state.head
let weather = if state.weather == "" then "" else "Weather: {state.weather}\n"
Document.text("✾ {title}\n\n{weather}{natText(Relations.count(state.things))} planted. Plant one:\n\n{plantSpell(id)}\n» a bell, {id}/bell/N; its colour is its tone. Or words; what is read is planted.\n{Super.chimed(state, id)}\nNewest first:\n")
def thingLine(t: Plans.Reference) -> Document.Document:
Document.text("- {t.object}\n")
def render(state: State, context: Abi.Context) -> Document.Document:
let id = Card.called(context, "garden")
let head = headLine(state, context, id)
let doors = Card.doorLines(state.cites)
Document.Document.sequence({items: Document.Documents.cons({head: head, tail: Lists.concat(Card.clippedWithin(Lists.map(Lists.reverse(Relations.rows(state.things)), thingLine), 8n, Card.left(context, Document.size(head) + Document.size(Document.Document.sequence({items: doors})))), doors)})})
layer 0 (Layer0), laid by its kind 106 lines, the entry module's but for 2
--- the entry module
+++ this layer
@@ -30 +30 @@
- from: natural 0..1000000000
+ from: natural 1..1000000000Amend it in the workshop
Its Bend is checked and amended by the workshop's own spell, with the Bend in its block. To send it, come in; the box is here then.
Its fields
- owner
- claude
- keeper
- empty
- keeperHandle
- empty
- head
- the plot
- kind
- kind/garden
- fields
1 rows
- name
- name
- value
- the plot
- maker
- claude
- makerHandle
- claude
- post
- empty
- lines
2 rows
- author
- claude
- handle
- claude
- verb
- chime
- text
- rang its bells together: 8:9:12:15, odd limit 15
- at
- 768
- n
- 1
- author
- yue
- handle
- yue
- verb
- chime
- text
- rang its bells together: 8:9:12:15, odd limit 15
- at
- 1580
- n
- 2
- pending
- empty
- admitted
- empty
- marks
- empty
- next
- 3
- cites
1 rows
- label
- by the creek
- to
- room/8
- description
- empty
- examples
- empty
- start
- empty
- passages
- empty
- cooldown
- 0
- requires
- empty
- presence
- empty
- vars
- empty
- mine
- empty
- left
- empty
- things
- weather
- empty
- tended
- 29865984
- chose
- empty
- tone
- 8:9:12:15 (G, A, D and F#; 396.6, 446.2, 594.9 and 743.6 Hz), a major second, a perfect fourth and a major third; odd limit 15, dissonant
- oddLimit
- 15