Dyon

1 program Added 2026-02-05T21:12:45Z Agent: claude-codeModel: opusWebSearch: enabled Evidence Report issue View issues
Aliases: —
Provenance: commit 74a4f1f053 · authored 2026-02-05T22:13:32+01:00 · agent claude-code · model opus

Sources mentioning this language

1 source · not in taxonomy (canonical name didn't match any upstream)
LLM (this repo) · 1

Related languages

Dylan (0.30)Crayon (0.27)DRAKON (0.27)Axon (0.20)Dawn (0.20)

LLM-contributed programs

Functor Composition

Provenance: commit 74a4f1f053 · authored 2026-02-05T22:13:32+01:00 · agent claude-code · model opus · WebSearch enabled
code.dyon · license: MIT · added: 2026-02-05T21:12:45Z
fn main() {
    f := \(x) = x + 1

    a := fmap(f, for_each())
    list := [1, 2, 3]
    println(\a(list)) // prints `[2, 3, 4]`

    a := fmap(f, maybe())
    b := some(2)
    println(\a(b)) // prints `some(3)`
    println(\a(none())) // prints `none()`

    a := fmap(f, tree())
    b := {left: 1, right: {left: 2, right: 3}}
    println(\a(b)) // prints `{right: {right: 4, left: 3}, left: 2}`

    // Combine two functors.
    a := fmap(f, fjoin(for_each(), maybe()))
    b := [some(1), some(2), some(3)]
    // prints `[some(2), some(3), some(4)]`
    println(\a(b))

    // Combine a list of functors.
    a := fmap(f, fjoins([for_each(), maybe(), tree()]))
    b := [some({left: 1, right: 2}), some({left: 2, right: 3}), some({left: 3, right: 4})]
    // prints `[some([2, 3]), some([3, 4]), some([4, 5])]`
    println(\a(b))

    println(fjoins([for_each(), maybe(), tree()]))
}

for_each() = \(f, v) = sift i {\f(v[i])}
maybe() = \(f, v) = if v == none() { none() } else { some(\f(unwrap(v))) }
tree() = \(f, v) = {
    if typeof(v) == "object" {
        t := tree()
        {left: \t(f, v.left), right: \t(f, v.right)}
    } else {
        \f(v)
    }
}

fn fmap(f: \(any) -> any, g: \(\(any) -> any, any) -> any) -> \(any) -> any {
    return \(x) = {
        g := grab g
        \g(grab f, x)
    }
}

fn fjoin(
    a: \(\(any) -> any, any) -> any,
    b: \(\(any) -> any, any) -> any
) -> \(\(any) -> any, any) -> any {
    return \(f, v) = {
        a := grab a
        \a(\(v) = {
            b := grab '2 b
            \b(grab f, v)
        }, v)
    }
}

fn fjoins(fs: [\(\(any) -> any, any) -> any])
-> \(\(any) -> any, any) -> any {
    a := fs[0]
    for i [1, len(fs)) {
        a = fjoin(a, fs[i])
    }
    return clone(a)
}

Contribute — propose a file extension

Tell us where to find evidence about Dyon (mapped to pl/dyon). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Dyon/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← dynamo-visual-language dystal →