In my experience learning, teaching, and watching other people learn FP, it's <i>far</i> easier to learn FP with a language which is actually designed for it, <i>e.g.</i>, Elm.<p>JavaScript isn't that. It carries too much legacy baggage. Too many gotchas; too many pointy bits. It's also just super noisy.<p>There's a reason why someone had to write <i>The Good Parts</i>. I don't buy the idea either that <i>modern</i> JavaScript is somehow devoid of the kinds of problems that existed when Crockford wrote that book. I mean, how many people <i>still</i> think that `const` gives you an immutable value?<p><i>n.b.</i> I'm not sure why the Haskell snippet was included. It's confusing, and doesn't even make sense given that `main` is defined twice.
IMO Redux is a terrible way to start learning functional programming. There is too much boilerplate code and other code (ie. reducer, selectors, side effects, react components) that will confuse beginners and make the goal of learning functional programming harder.<p>It's like telling someone who wants to learn to drive, here's the road laws book, car manual, car service manual, offroad rally driving guide and engine tuning manual.
While I use Redux, and I like the simplicity of the single application state and the reducer function. I don't see it as a good example of FP or even JavaScript.<p>The problem with Redux is that it takes many patterns that make sense in languages like Haskell or Elm but are not idiomatic in JS. For example, action types and the usual reducer switch statement is easier to write and extend in Haskell.<p>And is not idiomatic JavaScript either. It always baffles me that an action dispatch is a way of doing a method dispatch (and yes I know that unlike a method dispatch an action can be persisted, and broadcasted). But if you compare the boilerplate and concepts introduced by a simple action dispatch (action creator, action type, payload, thunk, middleware) with a simple method call, and you look at the benefits (late binding with the state, persistence)... I wonder why solutions like Zustand didn't come up before.<p>(note, I wrote state management code similar to Zustand for my personal projects, but one of the reasons to continue using Redux is that getting the Context updates right is hard... a problem solved by React-Redux with addition of nice tooling and collaboration from core React devs. As soon React adds fine-grained context state updates the reasons to continue using Redux for me are low).
Side note: I just published a brand-new "Redux Essentials" core docs tutorial. It teaches beginners "how to use Redux, the right way", using our latest recommended tools and practices, including Redux Toolkit for writing your Redux code, the React-Redux hooks API for interacting with Redux in your components, and use of single-file "slices" for a given feature's Redux logic. I'd encourage folks to check it out:<p><a href="https://redux.js.org/tutorials/essentials/part-1-overview-concepts" rel="nofollow">https://redux.js.org/tutorials/essentials/part-1-overview-co...</a><p>My next step will be to rewrite the existing "bottom-up" tutorial sequence to simplify explanations, remove outdated references, improve the explanation flow, and add more running examples.
<p><pre><code> main :: (RealWorld ->) ((), RealWorld)
</code></pre>
I've been doing haskell for a few months now. I don't think I have ever seen a expression like this. It looks like State. Is this even valid syntactically? I'm Probably bikeshedding.