ReasonML: A trial by combat
A somewhat contrived case study of trying to build stuff with Reason
So, I decided to give it a try. I set out to build something with reason that was something slightly more than involved a Hello World application, and test how the language fared in somewhat non trivial applications.
This exploration dovetailed nicely with a recent frustration of mine: nerdy note taking was not something that I’ve found good options for (I love note taking with markdown, and it bums me out that it seems one else does). So I figured I’d build my own. Enter maple notes, a simple note taking app web app which supports markdown! You can find the source here, and the actual project is hosted here, if you’re interested.
As I delved into some of the more niche requirements for my application, it started to get a bit more challenging:
The first issue I ran into was animations. Expandable menu bars don’t feel right without a bit of animation, and unfortunately the docs don’t really have much to go off of to help.
But, reason does have a reasonably good interop story for most common cases. This means that you can wrap React components and JS libraries to work with Reason. I chose to use react spring for my animations, but, getting it to play nice with Reason was not trivial. A pattern that makes a lot of sense for an animation library is passing a function down as the component of a child, so that way the animation component can tweak the parameters of that function to animate the UI. Unfortunately being a strongly typed language meant reason wanted a react component as a child, and well, a function just isn’t that.
However, this ended up taking about half the total time I spent working on this project.
But all in all, it’s better than vanilla