Skip to content

Instantly share code, notes, and snippets.

@cowboyd
cowboyd / 01-input.ts
Last active October 7, 2026 22:04
Hypothetical TUI Component Syntax
import {
ClackElement,
Focusable,
type TemplateExpansion,
type KeyDown,
type KeyRepeat,
fit,
percent,
reflects,
template,
@cowboyd
cowboyd / www-lib-revolution.ts
Created October 2, 2026 17:16
one-off revoution
import {
action,
createContext,
ensure,
once,
type Operation,
race,
resource,
suspend,
until,
@cowboyd
cowboyd / 01-app.ts
Last active September 25, 2026 14:08
Configliere transform schema
// checkpoint-options.ts
import { checkpoint, cli, command, description, name, option, schema, transform, version } from "configliere";
import type { ModelOf } from "configliere";
import { z } from "zod";
import { domain, endpoint, port, protocol } from "./schemas.ts";
export const app = command(
name("auth0"),
description("Provision and inspect Auth0 tenants."),
version("1.0.0"),
@cowboyd
cowboyd / configliere-conversation.md
Created September 25, 2026 03:25
Conversation with GPT about configliere multiple()

Unpack this for me. Was it like this before? What changed to make it this way. What is an example of the degenerative case?

I see one concern worth addressing: candidates() computes the Cartesian product of decoder candidates. Numeric-looking strings generally have multiple interpretations, so an invalid array schema could cause exponential validation work as repetitions increase. The generator makes successful cases lazy, but a failure may exhaust all (n^k) combinations. I’d either document why candidate counts are safely bounded or add a stress-oriented test/design limit.

did this change? again, unpack and examine

There’s also a smaller diagnostic edge: if several successful occurrences accumulate warnings and a later occurrence fails, the failure settles the parameter immediately and the earlier accumulated issues appear to be dropped. That may matter once successful reads produce meaningful diagnostics.

@cowboyd
cowboyd / mockup-logs-ui.html
Created February 25, 2026 16:37
Effection Inspector Logs UI Mockup
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Inspector Logs UI Mockup</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.19.1/cdn/themes/light.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.19.1/cdn/themes/dark.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.19.1/cdn/shoelace-autoloader.js"></script>
<style>
@cowboyd
cowboyd / EMR
Created February 4, 2026 15:27
Consuming Explicitly Managed Resources
import { main, type Operation, resource, until } from "@effection/effection";
class Thing {
constructor(public num: number) {}
async [Symbol.asyncDispose]() {
console.log(`[${this.num}]`, 'Adieu!');
}
}
export function using<T extends AsyncDisposable>(value: T): Operation<T> {
@cowboyd
cowboyd / json-reader.ts
Created September 5, 2025 22:16
Lazy JSONL reader in Effection
import {
call,
each,
main,
resource,
sleep,
type Stream,
until,
} from "@effection/effection";
import { TextLineStream } from "@std/streams";
@cowboyd
cowboyd / chat.ts
Created May 29, 2025 14:47
streaming effection chatbot resource
import type { Result, Stream } from "effection"
import { Ok, Err } from "effection";
function chat(history: Array<Message>): Stream<string, Result<void>> {
return resource<{
channel: Signal<string, void>;
await: Operation<E.Either<Error, void>>;
}>(function* (provide) {
const signal = yield* useAbortSignal();
const channel = createSignal<string, Result<void>>();
@cowboyd
cowboyd / 01-usage.ts
Last active March 6, 2025 15:06
An implementation of a finalizable transaction
import { finalizable, finalize } from "./finalizable.ts"
export function transaction(): Operation<string> {
return finalizable(function*() {
// on success
yield* finalize(function* (result) {
if (result.ok) {
console.log("everything is fine", result.value);
}
});
@cowboyd
cowboyd / buffered-channel.ts
Created November 18, 2024 18:57
A buffered Effection channel that exerts backpressure on the sender so that a maximum number of subscribers can be working on it at a time.
import { Operation, Channel, resource, Subscription, createChannel } from "./mod.ts";
export function createBufferedChannel<T, TDone>(max: number): Operation<Channel<T,TDone>> {
return resource(function* (provide) {
// the unbuffered channel.
let input = createChannel<T, TDone>();
// this channel is used to send whenever a working slot becomes available
let available = createChannel<void, never>();