4 ms·
Composition is table stakes now, I’d say pure functions (no side effects) are what make FP important with or without types.
by erik_seaberg 5y ago
Composition is table stakes now, I’d say pure functions (no side effects) are what make FP important with or without types.
- Zababa 5y agoI think the focus on "pure functions" is a bit Haskell-centric, as those are the guarantees that Haskell gives easily, but that's it. For example, Koka has total functions (https://koka-lang.github.io/koka/doc/book.html#why-effects https://koka-lang.github.io/koka/doc/book.html#why-effects), which gives more guarantees that pure functions. Lack of side effect is, I think, a side effect of searching for greater function composition. The goal of purity is to make functions easier to compose after all.
- JoelMcCracken 5y agoWell, you can still have pure functions without having an effects system. It just isn't checked. I think that's generally part of the mark of functional programming. If you do have side effects in some parts of the program then that part would be not functional.
- erik_seaberg 5y agoThat could be useful. Does Koka reject a total function that might not always terminate, or trust the author?
- Zababa 5y agoFrom what I understand, Koka relies on inference, so for example a function with a "while" or a recursive call will be marked as "div". I think the goal is to have the precision of Haskell, and even better, but without forcing the use of monads or something like that.