[Proof of Concept] Embedded functional scripting language with YAML ¯\_(ツ)_/¯

Overview

[YAML, fun]

Just an experimental project implementing embedded functional scripting language based on YAML syntax.

API docs for the standard library: src/Std.

Concept

Code:

:let:
  (+):
    :lambda: [x, y]
    :do:
      :+: [x, y]

  (==):
    :lambda: [x, y]
    :do:
      :==: [x, y]

  Maybe:
    :rec:
      map:
        :lambda: [callback, val]
        :do:
          :if: [(==), val, { :: null }]
          :then: val
          :else: [callback, val]

      withDefault:
        :lambda: [default, val]
        :do:
          :if: [(==), val, { :: null }]
          :then: default
          :else: val

  Cons:
    :rec:
      new:
        :lambda: [a, b, op]
        :do: [op, a, b]

      car:
        :lambda: [cons]
        :do:
          - cons
          - :lambda: [a, b]
            :do: a

      cdr:
        :lambda: [cons]
        :do:
          - cons
          - :lambda: [a, b]
            :do: b

  cons: [Cons.new, { :: 1 }, { :: 2 }]
  foobar:
    - (++)
    - { :: foo }
    - { :: bar }

  things:
    - (++)
    - :list:
        - foobar
        - cons
        - Maybe
        - [Cons.car, cons]
    - :: [1, 1.2, -9, null, bar]
:in:
  :rec:
    a: [Maybe.map, [(+), { :: 1 }], { :: 5 }]
    b: [Maybe.map, [(+), { :: 1 }], { :: null }]
    c: [Maybe.withDefault, { :: 0 }, { :: null }]
    d:
      - [Maybe.withDefault, { :: 0 }]
      - - [Maybe.map, [(+), { :: 1 }]]
        - - [Maybe.map, [(+), { :: 1 }]]
          - { :: 10 }
    e:
      :|>:
        - { :: 10 }
        - [Maybe.map, [(+), { :: 1 }]]
        - [Maybe.map, [(+), { :: 1 }]]
        - [Maybe.withDefault, { :: 0 }]

    f: [Cons.car, cons]
    g: [Cons.cdr, cons]
    h: [List.head, things]
    i:
      :|>:
        - [List.tail, things]
        - List.head
        - Cons.car

Result:

{a: 6, b: null, c: 0, d: 12, e: 12, f: 1, g: 2, h: "foobar", i: 1}

Things that (probably) work

Constant

:: foo

Variable

foo

Function

:lambda: [num1, num2]
:do:
  :+: [num1, num2]

Function Call

[func, arg1, arg2]

Chaining

:|>:
  - { :: 1 }
  - [(+), { :: 5 }]
  - [(+), { :: 4 }]

Record

:rec:
  a:
    :rec:
      b: { :: { 1: bar, true: baz } }
      '10': { :: foo }
  e: { :: { y: z } }

Record Field Access

foo.a.10
foo.a.b.(1)
:get: [foo, { :: a }, { :: b }, { :: 1 }]

Record Field Update

:update: foo
:set:
  a: { :: bar }
  oldFoo: foo
:unset: [e]

List

:list:
  - { :: a }
  - { :: 1 }
  - { :: 1.1 }
  - { :: -1 }
  - { :: true }
  - :list:
      - { :: nested }

If Else

:if:
  :==: [:: 2, :: 2]
:then: { :: yes }
:else: { :: no }

Let In

:let:
  a: { :: foo }
  b: a
:in: b

With

:let:
  args1:
    :rec:
      first: { :: 10 }
      second: { :: 20 }
  args2:
    ::
      third: 30
:in:
  :with: [args1, args2]
  :do:
    :+: [first, second, third]

Case Of

:let:
  handle:
    :lambda: [var]
    :do:
      :case: var
      :of:
        :==:
          1: { :: this is one }
          []: { :: this is empty list }
          bar: { :: this is bar }
        :(): { :: this null }
        :bool:
          :as: [b]
          :do: { :: this is a bool }
        :int:
          :as: [n]
          :do: { :: this is an int }
        :float:
          :as: [f]
          :do: { :: this is a float }
        :string:
          :as: [first, rest]
          :do: first
        :function:
          :as: [f]
          :do: { :: this is a function }
        :list:
          :as: [head, tail]
          :do: head
        :rec:
          :as: [r]
          :do: r.foo
        :_:
          :as: [wtf]
          :do: { :: 'wtf??' }
:in:
  :list:
    - [handle, { :: null }]
    - [handle, { :: true }]
    - [handle, { :: 1 }]
    - [handle, { :: 2 }]
    - [handle, { :: 1.1 }]
    - [handle, { :: foo }]
    - [handle, { :: bar }]
    - [handle, handle]
    - [handle, { :: [] }]
    - [handle, { :: [a, b] }]
    - [handle, { :: { foo: bar } }]

Platform Call

:platform: import
:arg: { :: ./concept.yml }
struct MyPlatform(DefaultPlatform);

impl Platform for MyPlatform { ... }

fn main() {
    let vm = Vm::new(MyPlatform(DefaultPlatform)).unwrap();
    ...
}

Embed into Rust

Here's how

Contribute

See CONTRIBUTING.md

You might also like...
This shows proof-of-concept implementation of lexer-parser-evaluator which allows setting custom values to keywords.

Custom Configurable Lexer-Parser Note This is still very experimental, and for any syntax error it will just panic giving very unhelpful error message

Proof of concept for a web API that can export 3MF files from parametric OpenSCAD models

Model API About A proof of concept for a web API that can export 3MF files from a parametric OpenSCAD model. A typical use would be to have a form on

Proof of Concept / Experiment: Use IDF-HAL-LL from bare metal Rust
Proof of Concept / Experiment: Use IDF-HAL-LL from bare metal Rust

Proof of Concept / Experiment: Use IDF-HAL-LL from BM Rust idf-ll-compile pre-compiles a static library for ESP32C3 and ESP32 esp-ll a simple crate th

A proof of concept Linux screen reader, with minimal features.

Odilia A proof of concept Linux screen reader, with minimal features. Status: prototype We're breaking things daily. This is not usable whatsoever, an

A proof-of-concept for building Orbiter spaceflight simulator addons in Rust

Orbiter spacecraft addon development in Rust This project is a proof of concept for creating a spacecraft addon for the Orbiter spaceflight simulator

Lumiere is a proof-of-concept/example video player built with the Slint UI framework and libmpv
Lumiere is a proof-of-concept/example video player built with the Slint UI framework and libmpv

Lumiere is a proof-of-concept/example video player built with the Slint UI framework and libmpv. This was built quickly to try out Slint and it's new OpenGL underlay feature.

A proof of concept file dropper utilizing PowerShell loosely based off
A proof of concept file dropper utilizing PowerShell loosely based off

A proof of concept file dropper utilizing PowerShell loosely based off

OGC API & STAC - Proof of Concept

OAPI - POC Proof of concept (POC) to ingest geospatial datasets from MeteoSuisse into a SpatioTemporal Asset Catalog (STAC), expose as OGC API Feature

JS Runtime proof-of-concept for interactions with AvdanOS

Important: we are migrating to a new Discord server .gg/avdanos What is this ? This repo aims to be a JavaScript environment where AvdanOS extensions

Massayo is a small proof-of-concept Rust library which removes AV/EDR hooks in a given system DLL

Massayo Massayo is a small proof-of-concept Rust library based on UnhookingPOC, which removes AV/EDR hooks in a given system DLL. I tried to reduce fi

Proof of concept of running WASM w/ Docker

docker-wasm This is a proof of concept: a simple HTTP server, written in rust and compiled to wasm. It should be run using the new Docker WASM technic

Proof of concept writing a monolith BBS using Rust, GraphQL, WASM, and SQL. WILL BE ARCHIVED ONCE PROVEN

GraphQL Forum Important DO NOT even think about using this in production, lest your sanity be destroyed and credentials lost! Loosely following the aw

Proof-of-concept on how to solve Bitcoin's light node sync problem with zkSNARKs
Proof-of-concept on how to solve Bitcoin's light node sync problem with zkSNARKs

BTC Warp Prove and verify the longest Bitcoin PoW chain BTC Warp is a proof-of-concept system that aims to solve the client-syncing problem for Bitcoi

Proof of concept implementation of ProtoGalaxy
Proof of concept implementation of ProtoGalaxy

protogalaxy-poc Proof of concept implementation of ProtoGalaxy (https://eprint.iacr.org/2023/1106.pdf) using arkworks. Experimental code, do not use i

Proof of concept implementation of Sigmabus

sigmabus-poc Proof of concept implementation of Sigmabus https://eprint.iacr.org/2023/1406, a cool idea by George Kadianakis and Mary Maller and Andri

Proof-of-concept Typst webapp alternative

Proof-of-Concept Typst Webapp Alternative With the following features: Collaborative editing (using operational-transform and referenced from ekzhang/

A proof of concept implementation of RTSP over Dahua P2P protocol.

RTSP Streaming with Dahua P2P Protocol Implementation This is a proof of concept implementation of RTSP over Dahua P2P protocol. It works with Dahua a

CVE-2024-24576 Proof of Concept
CVE-2024-24576 Proof of Concept

CVE-2024-24576-Exploit The Command::arg and Command::args APIs state in their documentation that the arguments will be passed to the spawned process a

Hiisi is a proof of concept libSQL written in Rust following TigerBeetle-style with deterministic simulation testing.
Hiisi is a proof of concept libSQL written in Rust following TigerBeetle-style with deterministic simulation testing.

Hiisi Proof of concept libSQL server written in Rust with deterministic simulation testing. Why Hiisi? SQLite is a versatile database, but serverless

Owner
Arijit Basu
Getting spoiled by Rust & Elm
Arijit Basu
Next-GEN Confguration Template Generation Language

Sap lang yet another configuration oriented language name comes from Sapphire which is the birthstone of september Language Feature the last expr of t

LemonHX 12 Aug 8, 2022
Next-GEN Confguration Template Generation Language

Sap lang yet another configuration oriented language name comes from Sapphire which is the birthstone of september Language Feature the last expr of t

Sap-Lang 12 Aug 8, 2022
🌽 A simple and pain-free configuration language.

?? Corn A simple and pain-free configuration language. Corn has been designed using inspiration from JSON and Nix to produce a language that's easy an

Jake Stanger 3 Nov 28, 2022
Interactive interpreter for a statement-based proof-of-concept language.

nhotyp-lang Nhotyp is a conceptual language designed for ease of implementation during my tutoring in an introductive algorithmic course at Harbin Ins

Geoffrey Tang 5 Jun 26, 2022
Rhai - An embedded scripting language for Rust.

Rhai - Embedded Scripting for Rust Rhai is an embedded scripting language and evaluation engine for Rust that gives a safe and easy way to add scripti

Rhai - Embedded scripting language and engine for Rust 2.4k Dec 29, 2022
Rhai - An embedded scripting language for Rust.

Rhai is an embedded scripting language and evaluation engine for Rust that gives a safe and easy way to add scripting to any application.

Rhai - Embedded scripting language and engine for Rust 2.4k Jan 3, 2023
A plugin system for the Rhai embedded scripting language.

Rhai Dylib This crate exposes a simple API to load dylib Rust crates in a Rhai engine using Rhai modules. ?? This is a work in progress, the API is su

Rhai - Embedded scripting language and engine for Rust 6 Dec 27, 2022
Proof-of-concept for a memory-efficient data structure for zooming billion-event traces

Proof-of-concept for a gigabyte-scale trace viewer This repo includes: A memory-efficient representation for event traces An unusually simple and memo

Tristan Hume 59 Sep 5, 2022
A proof of concept implementation of cyclic data structures in stable, safe, Rust.

A proof of concept implementation of cyclic data structures in stable, safe, Rust. This demonstrates the combined power of the static-rc crate and the

null 157 Dec 28, 2022
Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions

Introduction Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions. (hand interaction with boxes missing

Mika 52 Nov 14, 2022