Questions tagged [functional-programming]
For questions regarding functional programing concepts like immutability, closures, pure functions, and monads or regarding functional languages which enforce some or all of these constraints.
30 questions
Score of 0
0 answers
212 views
Attempt to make a memory-safe language with little cost: Can boxing work like this?
My programing language aims to be "C with functional programming". Being a fully functional language, it shall satisfy the following properties:
It has no mutable variables.
It has no ...
Score of 0
1 answer
451 views
Why aren't the performance benefits of Splay Trees offset by the fact that using them disables many compiler optimizations? [closed]
OK, maybe a stupid question, I know that quite a few programs have recently been sped up by using Splay Trees instead of self-balancing trees such as Red-Black Trees. But I don't understand how that ...
Score of 5
0 answers
177 views
Does a lazily evaluated language with effect typing exist? Can it exist?
Does a lazily evaluated language with effect typing exist? Can it exist?
It does not seem anyone has published one. Even a very crude research platform would be interesting.
Most, if not all, ...
Score of 10
2 answers
1979 views
What is switch statement fallthrough, in the perspective of functional programming?
In the switch statement of imperative languages such as C and JavaScript, the control flow "falls through" to the next case if you don't ...
Score of 4
1 answer
354 views
Why are there different typeclass hierarchies?
What's the history and reasoning behind the differences in the typeclass hierarchies in various functional programming language standard libraries? For instance, why does ...
Score of 7
1 answer
536 views
What problems do applicative functors solve, as an abstraction relative to monads and arrows?
TL;DR
This site is of course particularly interested in the language designer's and implementor's perspective so, following What is an arrow and what powers would it give as a first class concept in a ...
Score of 0
1 answer
620 views
Are there any programming languages that operate solely via side-effects?
Out of curiosity I checked how Google AI would respond to a similar question. The bot seemed clever enough to understand the question, but responded that functions in this case would have no return ...
Score of 6
0 answers
382 views
What challenges might still prevent compiler or JIT optimizations of common FP operations like map, filter, and reduce?
(While I'm referring to JS in my example, I don't intend to be constrained to JS: so any comments/answers concerning FP-style APIs for working with collections for any language are welcome and ...
Score of 3
2 answers
521 views
Does a Rust implementation of the Monkey programming language require a garbage collector?
Awhile back I wrote a Rust implementation of the Monkey programming language by Thorsten Ball (https://monkeylang.org/). When I got done with it I was a bit surprised that I never used an Arc/Rc ...
Score of 9
2 answers
530 views
Can total (primitive) corecursion be implemented?
I'm trying to understand how to implement corecursion in a total functional context. I've already implemented recursion using standard techniques (for loops) but I ...
Score of 7
2 answers
915 views
When do functional programming languages need advanced garbage collection?
While thinking about garbage collection, I realized a simple fact that a garbage collector that is more than reference counting is needed because there are circular references, but there are ...
Score of 1
2 answers
431 views
What is the mathematical abstraction of bitflags for use in a purely functional language?
A lot of C APIs like to have something called bit flags to signal the functions configuration options like Vulkan, OpenCL, SQLite and much more, it a typical pattern to it.
This common pattern of ...
Score of 9
7 answers
2022 views
Is there a generic way to refer to the current function in recursion?
In writing recursive functions (functional style), I often need to refer to the current function (depending on the context).
e.g.
f 0 = 0
f (S n) = f n + 2
Are ...
Score of 6
3 answers
3461 views
How to implement + in a language where functions accept only one argument? [closed]
While reading about currying, I found the argument that it is beneficial in languages, which have only functions accepting only one argument.
I am wondering how to implement a 2-ary function like the ...
Score of 30
5 answers
5388 views
Are there Haskell-like languages where equations allow for arbitrary left-hand sides?
In Haskell, you can define algorithms by equations that pattern-match on left-hand side constructors. For example:
...