Undo and redo in Elm
- Elm’s syntax is unusual and very similar to Haskell
- Data is immutable
- Architecture is a lot like Redux
- The way Elm deals with errors was robust
This was my third completed project with Elm. Elm is an ambitious language that makes bold claims: it aims for no runtime exceptions, is trying hard to be mainstream and common, and picks up syntax and ideas from languages like Haskell.
Elm looks a lot like Haskell, a purely functional language I was assigned to write for a short time in college. Haskell puzzled me and has fallen far short of “mainstream” - you might use Pandoc, a document converter written in Haskell, but for the most part it’s used by research laboratories or the rare cutting-edge usecase.
Try it out
Click on the gray box to draw a point. Click a drawn point to delete it. Click undo & redo to move through history.
How it works (abridged)
The initial learning curve for Elm felt steeper than ClojureScript, but once I grasped the syntax and got past the first slew of compiler errors, this project was an absolute delight. Writing the ClojureScript version gave me a taste of what it’d be like to implement in a natively immutable language. Writing Elm gave me that feeling but also the best experience with typechecking I’ve had. Especially with respect to Redux and Immutable, which are unfortunately blind spots for Flow, having instant type checking of values all the way through - from an event to the action to the model updater - was amazing.
- I was inspired by Justin Woo’s implementations of a scrolling table in lots of languages: focusing on the same problem gives me a good idea of how languages compare.