PyFL – new functional programming language from Bill Wadge
billwadge.com
billwadge.com
Wadge was a co-designer of Lucid, an influential dataflow language.
Y(a) = g(g) where g(x) = a(x(x));
But I think in PyFL functions are not automatically curried, so that's only applicable to functions of one argument.I like his syntactic sugar for what would be list comprehensions in Python:
nprime = not exist p in primes: n mod p == 0 end;
rather than Python's nprime = not [p for p in primes if n % p == 0]
but I wonder if the Python/Haskell approach offers more composability.That said, i do prefer PyFl's lambda syntax.
This is definitely a cool project, i could see myself using this.
Doesn't Python already de-structure?
Repackaged: does PyFL lose touch with the regular language?
I'd be curious to know: Does PyFL benefit from Python's libraries, in the way that Scala and Clojure can use Java libraries? Are there any syntactic similarities? Or does it just happen to be built on Python as an implementation detail?
Thank you for that.
I do not understand the "instead of" in the cited part and it makes me somewhat skeptical (so does the "Py" in the name).
f a b
f has to work as a function of two arguments; that it is also formally interpretable, but not necessarily useful, as a function of one argument is only a nice bonus.https://en.wikipedia.org/wiki/Argument_of_a_function
"For example, the binary function f(x, y) = x + y has two arguments, x and y, in an ordered pair (x, y)."
So, function application to an ordered pair, i.e., a tuple, does not use double parentheses. Also, of course, currying in Python is atrocious.
I so wish Python had valof/where already. And it’s the one feature I was surprised not to find in OCaml after seeing it in Haskell – why isn’t it more common?
x + y
where y = g(x, 17)
where x = f(42)
instead of let x = f(42) in
let y = g(x, 17) in
x + y average xs = total / count
where total = sum xs
count = length xs average (x, xs) = total / count
where (total, count) = Data.List.foldl' go (x, 1) xs
go (total, count) x = (total + x, count + 1)
In a naive interpreter, this will do one pass rather than two. A smart compiler like GHC can probably optimise away the entire list, getting a tight numeric loop (e.g. https://dl.acm.org/doi/10.1145/1291220.1291199 )ISWIM also inspired Lucid, so I guess PyFL would be a nephew of SASL in that case.