Skip to main content

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.

4 votes
1 answer
274 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 ...
nicoty's user avatar
  • 141
7 votes
1 answer
474 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 ...
D. Ben Knoble's user avatar
0 votes
1 answer
497 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 ...
Osr Workshops's user avatar
6 votes
0 answers
330 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 ...
Dai's user avatar
  • 161
3 votes
2 answers
447 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 ...
lamont's user avatar
  • 139
9 votes
2 answers
487 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 ...
Corbin's user avatar
  • 901
7 votes
2 answers
770 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 ...
user23013's user avatar
  • 3,314
1 vote
2 answers
371 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 ...
Delfin's user avatar
  • 155
9 votes
7 answers
2k 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 ...
tinlyx's user avatar
  • 467
6 votes
3 answers
3k 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 ...
ceving's user avatar
  • 376
30 votes
5 answers
5k 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: ...
MaiaVictor's user avatar
5 votes
2 answers
936 views

How does the map function work in stack-based languages?

In many languages, the map function takes a function and a list, and applies the function to each element of the list, returning a new list of the results. Some ...
alephalpha's user avatar
9 votes
2 answers
3k views

How do languages chain higher-order functions while still keeping performance?

How do different programming languages deal with the chaining of higher-order functions (ex. [1,2,3].foldl((a, b) => a+b, 0), ...
apropos's user avatar
  • 1,295
15 votes
3 answers
991 views

Towards a better default listlike datastructure for functional languages

In most functional languages I know of, linked lists are the default datastructure of choice for many operations. The benefits are clear - they're clearly encoded with ADTs, and can be utilised easily ...
blueberry's user avatar
  • 2,607
3 votes
1 answer
363 views

How can I design a Functor trait to handle trait?

In programming languages like Rust, variables of different types that implement the same trait can have different sizes, i.e., the number of bytes used in the memory representation of the type. For ...
Jw C's user avatar
  • 243

15 30 50 per page