News for hackers. Stuff that matters.
Re:Learn Functional Programming Visually by snarkypixel on Sunday February 14, 2021 @01:01PM (#26134488)
Redux in the react world is a good example of real-world application using pure functions and functional programming concepts.
Re:Learn Functional Programming Visually by Jestar342 on Sunday February 14, 2021 @01:22PM (#26134705)
Likewise most of the hooks (useReducer being the obvious primary example), and functional components in general. That's how 99% of functional programming is done - state and function are separate, first class, concepts. The line is very distinct.
Re:Learn Functional Programming Visually by sfvisser on Sunday February 14, 2021 @05:01PM (#26136679)
I don’t thinks hooks are a great example. Hooks are by definition effectful. Best compared to ‘Applicative’s in Haskell. (Not monadic unfortunately)

So a functional component in react using hooks is not pure. You can translate it into FP with a bit of magic, but requires a context. The line is not that distinct at all.

Re:Learn Functional Programming Visually by Jestar342 on Monday February 15, 2021 @10:43AM (#26143739)
Hooks themselves may not be good FP examples, however I meant the resultant functional components that you develop yourself usually are.
Re:Learn Functional Programming Visually by snarkypixel on Monday February 15, 2021 @03:04PM (#26146645)
Hooks are implicitly injecting whatever global state in your stateless components, so definitely not a good example of functional concepts imho.