Skip to content

Instantly share code, notes, and snippets.

@qexat
Last active April 16, 2025 13:23
Show Gist options
  • Save qexat/91d37da1ef4dd04e3cd981cd424e388d to your computer and use it in GitHub Desktop.
Save qexat/91d37da1ef4dd04e3cd981cd424e388d to your computer and use it in GitHub Desktop.
jekyll: a hyper-declarative, statically-typed programming language around environment manipulation

jekyll: a hyper-declarative, statically-typed programming language around environment manipulation

# x is introduced to the environment
{ ..?e } → { x := 3 ; ..?e }
# y too ; ?e is not the same row variable as the one above
{ ..?e } → { y := 5 ; ..?e }
# matching the current context on one that contains an x and a y
# which allows us to add them to introduce y
{ x ; y ; ..?e } → { z := x + y ; ..?e } 
# this is equivalent to the code above but written in a "one-shot" style
{ .. } as ?e
→ { x := 3 ; ..?e } as ?f
→ { y := 5 ; ..?f } as ?g
→ { z := x + y ; ..?g }

# the environment contains the types Int, IO, List that we will use,
# so let's explicit them
{ IO ; List ; Nat ; .. } as ?e
# plain [ ] are used for lists of statements
→ { a := [: 3, 5, 2 :] ; ..?e } as ?f
# all parameters expect keyword arguments (although they can be omitted when using pipes) 
→ { b := (List Nat).mapped (func := _ * 3 - 1) (over := a) ; ..?f } as ?g
→ { c := (List Nat).mapped (func := Nat.as_string) (over := b) ; ..?g }

# this doesn't manipulate the environment
(List Nat).iterated (func := IO.Terminal.print) (over := c)

# no need to write down the state of the environment before the introduction
# of variables if we have no dependency on it
→ { x := 3 ; .. }

{ String ; .. } as ?e
# functions
→ { greet name := "Hello, {name : String}!" name ; ..?e } as ?f
# by the way, `greet := "Hello, {name : String}!"` also works

# with local bindings!
→ { one_plus_two () := [ → { x := 1 ; y := 2 } ; x + y ] ; ..?f }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment