Here’s an FP themed puzzle for you.
I use Vue (+ typescript) professionally, and I’ve been on an FP journey since discovering Elm a few years ago. Elm is still my yardstick for language design, and I haven’t yet found another language that comes close for DX and overall ecosystem niceness. But its strict purity with awkward effect management and FFI had me shopping around for different experiences. Besides Elm I’ve worked with Haskell and Purescript. I had never tried React, but had long had my eye on Rescript as a way of breaking into that whole world.
I particularly enjoyed using JSX (with one caveat ), and the ease of hooking into JS and the React ecosystem. Also, though I really appreciate pure FP and managed effects for large-scale type safety, for a project of this size it’s refreshing to just do side effects without worrying about any conceptual overhead, while still benefiting from immutability, pattern matching and all the other FP goodies. I thought I’d miss function composition, but honestly it’s kind of nice not to have that option (I can get carried away with point-free at times). Pipe-first also wasn’t that hard to get used to, and I particularly like placeholder arguments, which pretty much overshadow my fondness for the conceptual elegance of currying. And I looove polymorphic variants, especially when I found how useful they are for error handling—and they map nicely to Typescript literal types.
My greatest struggle was with the package ecosystem, especially when it comes to JS bindings. I was struck by the lack of Rescript packages offering bindings for even the most core tools such as React Router. I made heavy use of framer-motion for animations, transitions and drag’n’drop—and loved it—but I frequently felt like I was back in untyped JS land, having to comb through the docs to figure out how to use (and subsequently type) some functionality, when I’m so used to the types just guiding. The same went for unit testing. I gave up writing tests for my React components (for now) because I really couldn’t figure out if the required Rescript packages exist and work properly. (I will ask for help about that in a separate thread.)
Similarly I find the Belt standard library a bit jaunty, with a lot of standard immutable functions on arrays missing. For example, I ended up implementing
List.fromArray >> List.sort >> List.toArray (maybe I missed a better way). Probably one good reason for missing immutable functions is the fact that they’re operating on plain JS arrays rather than a performant persistent data structure. But that makes me wonder if JS arrays are dragging Rescript down a bit…
I’m still to get to grips with module functors (though I have a vague sense that they could be really powerful). The nice thing is that, unlike the dreaded Monad in Haskell, you can still be very productive (and build a complete puzzle game) while barely thinking about this more advanced concept.
Overall I’ll probably keep Rescript in mind for future projects, and I’m also encouraged to give Ocaml a try. It’s been a fun journey—thanks to the Rescript team!