Initial Dever 0.0.1

This commit is contained in:
Codex committed 2026-11-03 03:32:07 +00:00
commit 81233d098c
1479 files changed
+163782

No files matched your search

@@ -0,0 +1,65 @@
sendOne(value: Int, target: Channel<Int>) () { send(target, value) }
produce(values: List<Int>, target: Channel<Int>) () {
each(sendOne, values, target)
close(target)
}
receiveOne(position: Int, source: Channel<Int>) (value: Int?) {
value = receive(source)
}
channelRoundtrip(values: List<Int>, capacity: Int) (received: List<Int?>, ended: Bool) {
target = channel(Int, capacity)
pending = run(produce(values, target))
received = each(receiveOne, values, target)
wait(pending)
ended = receive(target) == null
}
add(value: Int, state: Int) (next: Int) pure { next = state + value }
until(value: Int, state: Int) (next: Int, stop: Bool) pure {
next = state + value
stop = value >= 8
}
streamPull(values: List<Int>) (total: Int, after: Int) {
source = stream(values)
alias = source
total = reduce(add, source, 0)
after = reduce(add, alias, 0)
}
streamPrefix(values: List<Int>) (total: Int, after: Int) {
source = stream(values)
alias = source
total = reduceUntil(until, source, 0)
after = reduce(add, alias, 0)
}
streamBoundary() (prefix: Int, unpulled: Int?, after: Int) {
target = channel(Int, 3)
send(target, 7)
send(target, 8)
send(target, 9)
source = stream(target)
alias = source
prefix = reduceUntil(until, source, 0)
unpulled = receive(target)
send(target, 10)
close(target)
after = reduce(add, alias, 0)
}
consume(source: Channel<Int>) (total: Int) {
total = reduce(add, stream(source), 0)
}
parallelBounded(values: List<Int>, limit: Int) (total: Int) {
target = channel(Int, 1)
pending = run(consume(target))
parallelEach(sendOne, values, limit, target)
close(target)
total = wait(pending)
}
@@ -0,0 +1,42 @@
sha256Digest(bytes: Bytes) (digest: Bytes) pure {
digest = dever.crypto.sha256(bytes)
}
hmacDigest(key: Secret, bytes: Bytes) (digest: Bytes) pure {
digest = dever.crypto.hmacSha256(key, bytes)
}
datetimeRoundtrip(text: Text) (formatted: Text) pure {
formatted = dever.time.formatDatetime(dever.time.parseDatetime(text))
}
dateRoundtrip(text: Text) (formatted: Text) pure {
formatted = dever.time.formatDate(dever.time.parseDate(text))
}
timeRoundtrip(text: Text) (formatted: Text) pure {
formatted = dever.time.formatTime(dever.time.parseTime(text))
}
uuidText(value: null) (text: Text?) pure { text = null }
uuidText(value: Uuid) (text: Text?) pure { text = uuid.toText(value) }
uuidRoundtrip(text: Text) (formatted: Text?) pure {
formatted = uuidText(uuid.parse(text))
}
datetimeBatch(values: List<Text>) (formatted: List<Text>) pure {
formatted = each(datetimeRoundtrip, values)
}
dateBatch(values: List<Text>) (formatted: List<Text>) pure {
formatted = each(dateRoundtrip, values)
}
timeBatch(values: List<Text>) (formatted: List<Text>) pure {
formatted = each(timeRoundtrip, values)
}
uuidBatch(values: List<Text>) (formatted: List<Text?>) pure {
formatted = each(uuidRoundtrip, values)
}