My little functional language for Uxn, Funktal, is finally in a state good enough for a blog post:
"Funktal: a frugal functional programming language"
https://wimvanderbauwhede.codeberg.page/articles/funktal/
You can also try it out:
I got recursion working in #Funktal, 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.
Because #Funktal 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.
Another #Funktal 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.
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
The problem with #Funktal, my functional language for #Uxn, 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.
I am still doggedly plugging away at #Funktal, my statically typed functional language for #Uxn. 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.