r/functionalprogramming • u/ToreroAfterOle • Apr 12 '24
Question FP language "siblings"
I know this is a subjective thing, but I am just curious...
Which language does it feel most similar to work with as when you work with Scala and ZIO or Cats Effect? I have some suspicion Haskell (since I've read in passing that at least Cats Effect was heavily inspired by Haskell) and possibly OCaml might most closely fit the bill. But this is entirely based on speculation since I have no first hand experience doing anything meaningful with any other FP language besides Scala.
Does anyone have some insight they can share?
View all comments
Show parent comment
2
u/Apprehensive_Pea_725 Apr 14 '24
F# and Scala do not provide any means to tell if an expression is pure or not.
If an expression is pure you can substitute the definition with the body or vice versa, any time and get back the same result. And practically speaking you can do that only if the expression doesn't have side effects.
But if you don't have any standard means to tell if an expression is pure or not you can't substitute arbitrarily and if you do you have bug somewhere.
There are patterns and frameworks to guide you in writing pure code certainly, but this is left to the developer discipline to follow and respect them, and leaves particular areas of your application prone to be impure (eg logging)