8000 GitHub - vmchale/pizarnik: Stack-based, concatenative language with suggestive pattern-matching
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

vmchale/pizarnik

Repository files navigation

Pizarnik

Pizarnik is a stack-based, concatenative language with extensible cases and evocative syntax for pattern-matching.

Pattern-Match Arms as Functions

type B = {`t ⊕ `f};

if : a b `t -- a
   := [ `t⁻¹ drop ]

else : a b `f -- b
     := [ `f⁻¹ nip ]

choice : a a B -- a
       := [ { if & else } ]
@i prelude/fn

%-

type List a = { `nil ⊕ List(a) a `cons };

type NE a = { List(a) a `cons };

head : NE(a) -- a
     := [ { `cons⁻¹ nip } ]

foldr : [ a b -- b ] b List(a) -- b
      := [ { `nil⁻¹ nip
           & `cons⁻¹ [dup] dip3 rotl [rot [rot $] dip swap] dip foldr } ]

The same foldr works on nonempty lists and lists; head only works on nonempty lists.

Or-Patterns

& (with) forms or-patterns, viz.

@i prelude/fn

%-

type Ord = {`lt ⊕ `eq ⊕ `gt};

gt : Ord -- Bool
   := [ { { `lt⁻¹ & `eq⁻¹ } False & `gt⁻¹ True } ]

Solving the Expression Problem

See Blume, Acar, and Chae.

About

Stack-based, concatenative language with suggestive pattern-matching

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0