r/functionalprogramming • u/complyue • May 17 '21
Question Mutable closures break FP? If so, how is FP doing nowadays?
If you believe that classes break FP, then you must believe that closures do as well.
Apparently realworld programming with only pure functions is not a solved problem today. Though Algebraic Effects & Handlers is seemingly the faithful future, it hasn't matured & got battle tested yet.
Before that, is FP considered broken for now?
3
u/ari_zerner May 17 '21
What do you mean? You don't need mutability.
2
u/complyue May 18 '21
I think pure closures is pretty okay to be considered FP, so not part of the concern I'm pondering about.
2
3
u/Dark_Ethereal May 22 '21
In Haskell folks have been doing real world programming with a purely functional language for years without algebraic effects.
To think purely functional programming implies an inability to make a program that has effects is to misconstrue what purity is all about.
It's about making functions that talk about effects rather than functions that do effects on evaluation.
1
u/gyre_gimble May 22 '21
Haskell has many implementations of algebraic effects.
1
0
May 18 '21
[deleted]
2
u/complyue May 18 '21 edited May 18 '21
Monadic effects is mature and battle tested, yes, I should have mentioned that. My issue with monadic effects mainly is composibility, e.g. STM can only run as base monad of the mtl stack, you can't compose/stack STM atop another monad stack to have the effect of transaction delimitation. It might only be a tradeoff in design of stm, but given so usefull stm is and the maturity it gained, I believe there must exist major complexity/difficulity prevented its authors to upgrade it into a monad transformer, as other mainstream monads have been. If effect handler based, I guess no transformer would ever be needed, and all effects easily composable.
Looking at Elm, I would regard Elm Runtime the monolithic effects handler. Too far from composable effects, it's even closed from extension by 3rd parties, I did see some of its power users complain about it, while the authors state that's the advantage they want to keep for themselves - some open source verson of vendor lockin I guess.
I mean only with effects handlers, effect consuming app and lib code can go "pure" in the sense all effects are declared for use, so they are not side-effects anymore.
1
u/gyre_gimble May 22 '21 edited May 22 '21
Algebraic effects is an alternative to monad stacks. Both are not sugar but different representations to express and mix various effects.
Elm isn’t very popular. Coq is a proof assistant. Why do you spread so much misinformation?
0
May 23 '21
[deleted]
1
u/gyre_gimble May 23 '21
What you wrote only shows how incompetance quickly devolves into bullshit.
0
May 23 '21
[deleted]
0
6
u/fl00pz May 17 '21
Is OOP broken if you write code outside of a class/object?