WimⓂ️ · @wim_v12e
253 followers · 1033 posts · Server merveilles.town

My little functional language for Uxn, Funktal, is finally in a state good enough for a blog post:

"Funktal: a frugal functional programming language"

wimvanderbauwhede.codeberg.pag

You can also try it out:

codeberg.org/wimvanderbauwhede

#uxn #Funktal

Last updated 1 year ago

WimⓂ️ · @wim_v12e
246 followers · 985 posts · Server merveilles.town

I got recursion working in , and now I can write this fixedpoint factorial:

-- the fixedpoint function
functions {
fix = (\f. f f apply )
}

main {
5
`(\ n <- f .
`(1)
`( n n 1 - f f apply * )
n 1 ==
if
) fix print
}

This actually works, even if it is still a bit rough around the edges.

#Funktal

Last updated 1 year ago

WimⓂ️ · @wim_v12e
245 followers · 964 posts · Server merveilles.town

Because uses postfix expressions, there is no need for parentheses to group subexpressions. So I use the parentheses to delimit lambda functions. That is perhaps counter-intuitive but I prefer it over, say, [] or {}.

Funktal is strict, so any function gets applied right away. And it supports lambdas without arguments. So you can write something like

( 6 7 * )

and it will do the same as

6 7 *

but the parenthesised version is a function application.

#Funktal

Last updated 1 year ago

WimⓂ️ · @wim_v12e
245 followers · 962 posts · Server merveilles.town

Another example:

types {
Bool = True | False
}

main {
`( 42 print ) `( 43 print ) True if
}

booleans in Funktal are just an ordinary sum type.
Lambdas with an argument are (\ ... . ...) but Funktal allows "lambdas" without argument, for computations that take no inputs.
the backtick means the expression is not evaluated but passed as an argument to the function.
The `if` is a builtin which executes conditionally.

#Funktal

Last updated 1 year ago

WimⓂ️ · @wim_v12e
241 followers · 954 posts · Server merveilles.town

Currently, there is no type checking. It's all very bare bones, an awful lot is still missing. But I think progress should be a bit faster now.

#Funktal

Last updated 1 year ago

WimⓂ️ · @wim_v12e
241 followers · 953 posts · Server merveilles.town

Finally, my compiler can emit correct for some simple examples.

The first one shows named functions, lambda functions and primitive types:

functions {
sq = (\Int <- x:Int. x x *)
}

main {
6 7 (\ Int <- x:Int <- y:Int . x y * sq )
print
}

#uxntal #Funktal

Last updated 1 year ago

WimⓂ️ · @wim_v12e
240 followers · 836 posts · Server merveilles.town

The problem with , my functional language for , is that very likely, nobody will want to use it because it lacks features. You know how this goes: if I release it bare-bones, a few people try it, they will be put off because of the lack of what they consider essential features, and that's it, as you have only ever one chance.

#uxn #Funktal

Last updated 2 years ago

WimⓂ️ · @wim_v12e
219 followers · 590 posts · Server merveilles.town

I am still doggedly plugging away at , my statically typed functional language for . It turns out to be one of the more complex bits of code I've worked on. One reason is that I am coding it in a very old style: the only type of datastructure I use is a fixed-size array of 1-byte or 2-byte integers.

#uxn #Funktal

Last updated 2 years ago