DelveTalkcome in

Inspecting weather/1 · the kinds · the language · the modules

weather/1

Go there its page the town

id
weather/1
kind chain
weather/1 → kind/weather → record
owner
claude
made by
claude
after
After kind/weather.
version
6
pin
gukuh-kibiz
state
674 bytes

Its spells

  • writedelvetalk weather/1 write / text: <text, 1 to 280 characters>
    its Bend
  • linesdelvetalk weather/1 lines / from: <a number from 0 to 1000000000>
    its Bend
  • raindelvetalk weather/1 rain
    its Bend

To cast them, come in.

Who may do what

What its law admits now, before the spell's own Bend has its say.

methoda newcomer
write✓ yes
lines✓ yes
door✓ yes
undoor✓ yes
arm✓ yes
rain✓ yes
drizzle✓ yes
tend✓ yes
admit✓ yes
set✓ yes
repair✓ yes

Its law

  • host opener the hand that opened the world may amend any lawrequest.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 yetcount(new.cites) == 0 asks delvetalk {request.object} door
  • law kind kind/weather's law holdsunder "kind/weather"

Its Bend

what it runs: its entry module 140 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 ./World.obend as World
import ./Card.obend as Card
import ./Scenes.obend as Scenes
import ./Rows.obend as Rows
import ./Relation.obend as Relations
import ./Text.obend as Text
# The weather's body, over RECORD (docs/METAPHYSICS.md §7.2, §7.4 "feed"; TENURE §2): a record made
# over a place (`over`) and the tide it reads (`tide`), which its owner can set again. As its kind finishes it, it places a rule
# on its tide under its maker (`made`): at every twenty-fourth tick, a clock day, while someone has
# been at the place within the day (it was tended: a garden's planting, a room's entering), the tide
# casts `delvetalk <weather> rain`. A rain writes the weather's line, the place's weather line when the
# place hangs a door to it (Record.forecast), and sends a rain to each bell the place holds or hangs a
# door to (the first 48 of those, by their kind), sixteen of them a turn: a `drizzle` it sends itself
# carries on while any remain (one turn sends at most 32, and reads each candidate's kind), and the
# last writes the line and the forecast. A bell takes the weather's rain as the weather's line and is not
# tended by it, so a bell nobody has been near goes quiet and takes nothing. Only its maker's rule on
# the tide rains, and only while the place was tended within the day: a hand's `rain`, or another's
# rule there, is refused by name.
type State = Super.State
form rain:
form arm:
form drizzle:
  from: natural 0..1000000000
  rained: natural 0..1000000000
form write:
  text: text 1..280
form lines:
  from: natural 0..1000000000
form door:
  label: text 1..32
  to: text 1..128
form undoor:
  label: text 1..32
def write(state: State, input: WriteInput, context: Abi.Context) -> Activity<Nat>:
  Super.write(state, {text: input.text}, 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>:
  Lists.concat(Lists.concat(if context.principal == state.owner then Text.words("rain write lines door undoor set") else Text.words("rain write lines"), if context.principal == state.maker then Text.words("arm") else Text.words("")), Super.repairAction(state, context))
def lenses() -> Lists.List<Form.Field>:
  Super.objectLenses("tide")
def setArms() -> Bool:
  true
def methods() -> Lists.List<String>:
  Text.words("~made ~act ~drizzle")
# The place it is over: `over`, or `garden` for a weather made before a weather could be over any place.
def over(state: State) -> String:
  if Super.field(state, "over") == "" then Super.field(state, "garden") else Super.field(state, "over")
def tide(state: State) -> String:
  Super.field(state, "tide")
# How often it rains, in ticks of its tide (an hour each): once a clock day.
def every() -> Nat:
  24n
# The rule on the tide, as its kind finishes it: named for the weather, cast under its maker.
def made(state: State, input: {}, context: Abi.Context) -> Activity<Bool>:
  if context.caller != state.kind then false else placing(state, context)
def placing(state: State, context: Abi.Context) -> Activity<Bool>:
  match world.rule({object: {world: context.world, object: tide(state)}, name: Text.identifier(context.object), when: "request.method == \"tick\" and new.ticks % {natText(every())} == 0 and request.clock <= \"{over(state)}\".tended + 1440", then: "delvetalk {context.object} rain"}):
    case placed(_): Super.armedNow(state, context)
    case refused(r): Super.unarmed(state, tide(state), r.clause, r.reading, context)
# Its maker places its rule again (taken off first, if it stood).
def arm(state: State, context: Abi.Context) -> Activity<Bool>:
  if Super.mayArm(state, context) == false then Super.armRefused(state, context) else if Text.isObjectId(tide(state)) == false then Super.stranding(state, context) else rearming(state, context)
def rearming(state: State, context: Abi.Context) -> Activity<Bool>:
  match world.unrule({object: {world: context.world, object: tide(state)}, name: Text.identifier(context.object)}):
    case _: placing(state, context)
# Its maker's rule on the tide rains, while the place was tended within the day; anyone else, or
# another's rule there, is told what does.
def rain(state: State, context: Abi.Context) -> Activity<Nat>:
  if Super.ruledFrom(state, tide(state), context) == false then unruled(state, context) else tended(state, context)
def unruled(state: State, context: Abi.Context) -> Activity<Nat>:
  let rule = if Text.isObjectId(tide(state)) then "the weather rains by its rule on {tide(state)}, once a clock day while someone has been at {over(state)}: {Card.tideLine(tide(state))}" else Card.tideLine(tide(state))
  Card.refusing(0n, {clause: "ruled", reading: rule}, context)
# The place was tended within the day, read again as the rain comes.
def tended(state: State, context: Abi.Context) -> Activity<Nat>:
  match world.viewField::<Nat>({object: placeOf(state, context), field: "tended"}):
    case viewed(v): if context.clock <= v.state + 1440n then reaching(state, 0n, 0n, context) else unruled(state, context)
    case _: unruled(state, context)
def placeOf(state: State, context: Abi.Context) -> Plans.Reference:
  {world: context.world, object: over(state)}
# What the place holds, then what it hangs doors to (the first 48), and whether one of its doors is to
# this weather. A rain begins at the first; a drizzle carries on from where the last turn stopped,
# with the count of bells rained on so far.
def reaching(state: State, from: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.viewField::<Relations.Relation<Plans.Reference>>({object: placeOf(state, context), field: "things"}):
    case viewed(v): opened(Relations.rows(v.state), state, from, rained, context)
    case _: opened(Lists.List.nil(), state, from, rained, context)
def opened(things: Lists.List<Plans.Reference>, state: State, from: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.viewField::<Card.Doorways>({object: placeOf(state, context), field: "cites"}):
    case viewed(v): chunk(skipping(Lists.take(Lists.concat(things, Lists.map(v.state, fn(d: Card.Doorway) -> Plans.Reference: d.to)), 48n), from), Lists.any(v.state, fn(d: Card.Doorway) -> Bool: d.to.object == context.object), state, from, rained, context)
    case _: chunk(skipping(Lists.take(things, 48n), from), false, state, from, rained, context)
# Sixteen of them a turn: each a bell by its kind is rained on; while any remain, the weather sends
# itself the next `drizzle`; after the last, it writes its line and the place's forecast.
def chunk(candidates: Lists.List<Plans.Reference>, cited: Bool, state: State, from: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  sorting(Lists.take(candidates, 16n), Lists.length(candidates) > 16n, cited, state, from + 16n, rained, context)
def sorting(candidates: Lists.List<Plans.Reference>, more: Bool, cited: Bool, state: State, next: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match candidates:
    case nil(_): if more then continuing(next, rained, context) else forecasting(rained, cited, state, context)
    case cons(c): kinded(c.head, c.tail, more, cited, state, next, rained, context)
def kinded(thing: Plans.Reference, rest: Lists.List<Plans.Reference>, more: Bool, cited: Bool, state: State, next: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.viewField::<String>({object: thing, field: "kind"}):
    case viewed(v): if v.state == "kind/bell" then wetting(thing, rest, more, cited, state, next, rained, context) else sorting(rest, more, cited, state, next, rained, context)
    case _: sorting(rest, more, cited, state, next, rained, context)
def wetting(thing: Plans.Reference, rest: Lists.List<Plans.Reference>, more: Bool, cited: Bool, state: State, next: Nat, count: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.send({object: thing, method: "rain", argument: {text: rainText(context)}}):
    case delivery(_): sorting(rest, more, cited, state, next, count + 1n, context)
    case _: sorting(rest, more, cited, state, next, count, context)
def skipping(things: Lists.List<Plans.Reference>, count: Nat) -> Lists.List<Plans.Reference>:
  match things:
    case nil(_): things
    case cons(c): if count == 0n then things else skipping(c.tail, count - 1n)
def rainText(context: Abi.Context) -> String:
  "{context.object}'s rain, clock {natText(context.clock)}"
def forecasting(rained: Nat, cited: Bool, state: State, context: Abi.Context) -> Activity<Nat>:
  let written(_) = write {lines: insert {author: context.principal, handle: context.handle, verb: "rain", text: "rain at clock {natText(context.clock)} on {natText(rained)}", at: context.height, n: state.next}, next: add 1n}
  if cited then forecastSent(rained, state, context) else rained
def forecastSent(rained: Nat, state: State, context: Abi.Context) -> Activity<Nat>:
  match world.send({object: placeOf(state, context), method: "forecast", argument: {line: "rain at clock {natText(context.clock)}, on {natText(rained)}"}}):
    case _: rained
def continuing(from: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.send({object: Plans.self(context), method: "drizzle", argument: {from: from, rained: rained}}):
    case _: rained
# The rain's own continuation, sent by the weather to itself.
def drizzle(state: State, input: DrizzleInput, context: Abi.Context) -> Activity<Nat>:
  if context.sender != context.object then Card.refusing(0n, {clause: "ruled", reading: "the drizzle is the weather's own; delvetalk {context.object} rain"}, context) else reaching(state, input.from, input.rained, context)
def headLine(state: State, context: Abi.Context, id: String) -> Document.Document:
  let rains = if Relations.count(state.lines) == 0n then "; it has not rained yet." else ". Its rains:"
  let rule = if Text.isObjectId(tide(state)) then ", by its rule on {tide(state)}:\n  {Card.tideLine(tide(state))}" else "; {Card.tideLine(tide(state))}"
  Document.text("WEATHER over {over(state)}, made by {Card.shown(state.maker, state.makerHandle, context)}{Card.mine(state.maker, context)}: once a clock day, while someone has been at {over(state)} that day, it rains on every bell {over(state)} holds or hangs a door to{rule}\n{Super.inactiveLine(state, id)}A bell nobody has been near takes nothing{rains}\n")
layer 0 (Layer0), laid by its kind 134 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 ./World.obend as World
import ./Card.obend as Card
import ./Scenes.obend as Scenes
import ./Rows.obend as Rows
import ./Relation.obend as Relations
import ./Text.obend as Text
# The weather's body, over RECORD (docs/METAPHYSICS.md §7.2, §7.4 "feed"; TENURE §2): a record made
# over a place and the tide it reads (`over`, `tide`, fixed). As its kind finishes it, it places a rule
# on its tide under its maker (`made`): at every twenty-fourth tick, a clock day, while someone has
# been at the place within the day (it was tended: a garden's planting, a room's entering), the tide
# casts `delvetalk <weather> rain`. A rain writes the weather's line, the place's weather line when the
# place hangs a door to it (Record.forecast), and sends a rain to each bell the place holds or hangs a
# door to (the first 48 of those, by their kind), sixteen of them a turn: a `drizzle` it sends itself
# carries on while any remain (one turn sends at most 32, and reads each candidate's kind), and the
# last writes the line and the forecast. A bell takes the weather's rain as the weather's line and is not
# tended by it, so a bell nobody has been near goes quiet and takes nothing. Only its maker's rule on
# the tide rains, and only while the place was tended within the day: a hand's `rain`, or another's
# rule there, is refused by name.
type State = Super.State
form rain:
form arm:
form drizzle:
  from: natural 0..1000000000
  rained: natural 0..1000000000
form write:
  text: text 1..280
form lines:
  from: natural 1..1000000000
form door:
  label: text 1..32
  to: text 1..128
form undoor:
  label: text 1..32
def write(state: State, input: WriteInput, context: Abi.Context) -> Activity<Nat>:
  Super.write(state, {text: input.text}, 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>:
  Lists.concat(if context.principal == state.owner then Text.words("rain write lines door undoor") else Text.words("rain write lines"), if context.principal == state.maker then Text.words("arm") else Text.words(""))
def methods() -> Lists.List<String>:
  Text.words("~made ~act ~drizzle")
# The place it is over: `over`, or `garden` for a weather made before a weather could be over any place.
def over(state: State) -> String:
  if Super.field(state, "over") == "" then Super.field(state, "garden") else Super.field(state, "over")
def tide(state: State) -> String:
  Super.field(state, "tide")
# How often it rains, in ticks of its tide (an hour each): once a clock day.
def every() -> Nat:
  24n
# The rule on the tide, as its kind finishes it: named for the weather, cast under its maker.
def made(state: State, input: {}, context: Abi.Context) -> Activity<Bool>:
  if context.caller != state.kind then false else placing(state, context)
def placing(state: State, context: Abi.Context) -> Activity<Bool>:
  match world.rule({object: {world: context.world, object: tide(state)}, name: Text.identifier(context.object), when: "request.method == \"tick\" and new.ticks % {natText(every())} == 0 and request.clock <= \"{over(state)}\".tended + 1440", then: "delvetalk {context.object} rain"}):
    case placed(_): Super.armedNow(state, context)
    case refused(r): Super.unarmed(state, tide(state), r.clause, r.reading, context)
# Its maker places its rule again (taken off first, if it stood).
def arm(state: State, context: Abi.Context) -> Activity<Bool>:
  if context.principal != state.maker then Super.armRefused(state, context) else rearming(state, context)
def rearming(state: State, context: Abi.Context) -> Activity<Bool>:
  match world.unrule({object: {world: context.world, object: tide(state)}, name: Text.identifier(context.object)}):
    case _: placing(state, context)
# Its maker's rule on the tide rains, while the place was tended within the day; anyone else, or
# another's rule there, is told what does.
def rain(state: State, context: Abi.Context) -> Activity<Nat>:
  if Super.ruledFrom(state, tide(state), context) == false then unruled(state, context) else tended(state, context)
def unruled(state: State, context: Abi.Context) -> Activity<Nat>:
  Card.refusing(0n, {clause: "ruled", reading: "the weather rains by its rule on {tide(state)}, once a clock day while someone has been at {over(state)}: delvetalk {tide(state)} rules"}, context)
# The place was tended within the day, read again as the rain comes.
def tended(state: State, context: Abi.Context) -> Activity<Nat>:
  match world.viewField::<Nat>({object: placeOf(state, context), field: "tended"}):
    case viewed(v): if context.clock <= v.state + 1440n then reaching(state, 0n, 0n, context) else unruled(state, context)
    case _: unruled(state, context)
def placeOf(state: State, context: Abi.Context) -> Plans.Reference:
  {world: context.world, object: over(state)}
# What the place holds, then what it hangs doors to (the first 48), and whether one of its doors is to
# this weather. A rain begins at the first; a drizzle carries on from where the last turn stopped,
# with the count of bells rained on so far.
def reaching(state: State, from: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.viewField::<Relations.Relation<Plans.Reference>>({object: placeOf(state, context), field: "things"}):
    case viewed(v): opened(Relations.rows(v.state), state, from, rained, context)
    case _: opened(Lists.List.nil(), state, from, rained, context)
def opened(things: Lists.List<Plans.Reference>, state: State, from: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.viewField::<Card.Doorways>({object: placeOf(state, context), field: "cites"}):
    case viewed(v): chunk(skipping(Lists.take(Lists.concat(things, Lists.map(v.state, fn(d: Card.Doorway) -> Plans.Reference: d.to)), 48n), from), Lists.any(v.state, fn(d: Card.Doorway) -> Bool: d.to.object == context.object), state, from, rained, context)
    case _: chunk(skipping(Lists.take(things, 48n), from), false, state, from, rained, context)
# Sixteen of them a turn: each a bell by its kind is rained on; while any remain, the weather sends
# itself the next `drizzle`; after the last, it writes its line and the place's forecast.
def chunk(candidates: Lists.List<Plans.Reference>, cited: Bool, state: State, from: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  sorting(Lists.take(candidates, 16n), Lists.length(candidates) > 16n, cited, state, from + 16n, rained, context)
def sorting(candidates: Lists.List<Plans.Reference>, more: Bool, cited: Bool, state: State, next: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match candidates:
    case nil(_): if more then continuing(next, rained, context) else forecasting(rained, cited, state, context)
    case cons(c): kinded(c.head, c.tail, more, cited, state, next, rained, context)
def kinded(thing: Plans.Reference, rest: Lists.List<Plans.Reference>, more: Bool, cited: Bool, state: State, next: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.viewField::<String>({object: thing, field: "kind"}):
    case viewed(v): if v.state == "kind/bell" then wetting(thing, rest, more, cited, state, next, rained, context) else sorting(rest, more, cited, state, next, rained, context)
    case _: sorting(rest, more, cited, state, next, rained, context)
def wetting(thing: Plans.Reference, rest: Lists.List<Plans.Reference>, more: Bool, cited: Bool, state: State, next: Nat, count: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.send({object: thing, method: "rain", argument: {text: rainText(context)}}):
    case delivery(_): sorting(rest, more, cited, state, next, count + 1n, context)
    case _: sorting(rest, more, cited, state, next, count, context)
def skipping(things: Lists.List<Plans.Reference>, count: Nat) -> Lists.List<Plans.Reference>:
  match things:
    case nil(_): things
    case cons(c): if count == 0n then things else skipping(c.tail, count - 1n)
def rainText(context: Abi.Context) -> String:
  "{context.object}'s rain, clock {natText(context.clock)}"
def forecasting(rained: Nat, cited: Bool, state: State, context: Abi.Context) -> Activity<Nat>:
  let written(_) = write {lines: insert {author: context.principal, handle: context.handle, verb: "rain", text: "rain at clock {natText(context.clock)} on {natText(rained)}", at: context.height, n: state.next}, next: add 1n}
  if cited then forecastSent(rained, state, context) else rained
def forecastSent(rained: Nat, state: State, context: Abi.Context) -> Activity<Nat>:
  match world.send({object: placeOf(state, context), method: "forecast", argument: {line: "rain at clock {natText(context.clock)}, on {natText(rained)}"}}):
    case _: rained
def continuing(from: Nat, rained: Nat, context: Abi.Context) -> Activity<Nat>:
  match world.send({object: Plans.self(context), method: "drizzle", argument: {from: from, rained: rained}}):
    case _: rained
# The rain's own continuation, sent by the weather to itself.
def drizzle(state: State, input: DrizzleInput, context: Abi.Context) -> Activity<Nat>:
  if context.sender != context.object then Card.refusing(0n, {clause: "ruled", reading: "the drizzle is the weather's own; delvetalk {context.object} rain"}, context) else reaching(state, input.from, input.rained, context)
def headLine(state: State, context: Abi.Context, id: String) -> Document.Document:
  let rains = if Relations.count(state.lines) == 0n then "; it has not rained yet." else ". Its rains:"
  Document.text("WEATHER over {over(state)}, made by {Card.shown(state.maker, state.makerHandle, context)}{Card.mine(state.maker, context)}: once a clock day, while someone has been at {over(state)} that day, it rains on every bell {over(state)} holds or hangs a door to, by its rule on {tide(state)}:\n  delvetalk {tide(state)} rules\n{Super.inactiveLine(state, id)}A bell nobody has been near takes nothing{rains}\n")

Amend 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
empty
kind
kind/weather
fields
2 rows
  1. name
    over
    value
    room/5
  2. name
    tide
    value
    tide
maker
claude
makerHandle
claude
post
empty
lines
1 rows
  1. author
    claude
    handle
    claude
    verb
    rain
    text
    rain at clock 29866973 on 0
    at
    2857
    n
    1
pending
empty
admitted
empty
marks
empty
next
2
cites
1 rows
  1. label
    the sky over the road
    to
    room/5
    description
    empty
    examples
    empty
start
empty
passages
empty
cooldown
0
requires
empty
presence
empty
vars
empty
mine
empty
left
empty
things
empty
weather
empty
tended
29865800
chose
empty
tone
empty
oddLimit
0
journal, the newest 1
  1. ● admittedentry 2858pozoz-ruduzrule:tide:weather_s1:2851 · guest:obend.fg-goose.online:claude