I reported two months back on starting a JavaScript app called Kakuro Master. I worked on it for a little while, but discovered that generating new board layouts is hard, so I lost interest. Well, my interest has returned, due to learning a new programming language, Elm.
Logo Credit: @elmlang
Elm is basically a simplified Haskell, that compiles into JavaScript, and has a nice run-time that makes it easy to use it to create webapps. The apps can be embedded inside an existing web page, or you can give Elm the whole screen, and write no HTML, CSS, or JavaScript, except via Elm libraries that generate it.
When I started looking around the Elm code on GitHub, I discovered that the Elm compiler is written in Haskell. I didn't recognize the similarity until then, having very little experience with Haskell. So I went back to a tutorial that I had started a while back: Learn You a Haskell for Great Good! I learned enough to write my first Haskell program, and I was hooked. I've been thinking my next programming language would be Elixir/Erlang, but I think now that it will be Haskell on the server and Elm on the client, though a lot depends on who offers to pay me for playing (Clojure also doesn't suck, though I'm not happy about its dependence on Java).
Elm and Haskell (and Elixir and Erlang) are a bit weird for most programmers. They are all pure functional languages. All data is read-only. You can create new versions of data structures that share lots of components, but there is never an issue of locking around state changes, because values are immutable. There are a few exceptions to this, since they're necessary for interaction between processes and for I/O, but they're limited, and designed to make it easy to avoid deadlock.
Haskell is also lazy. Nothing is computed until you ask for it. You can create lists of infinite length, but unless you try to print one, or map over the whole thing, it will never actually be created. Very cool.
I'm not going to bother with examples. If you're interested, take a gander at Learn You a Haskell..., or work through the Elm tutorial.
So I've started converting Kakuro Master to Elm. I have the basic interface looking pretty much as it used to. Now I need to go back to the board generation code. Once I get that done, I'll write the code to display the board with sums for rows and columns, instead of the debugging output it has now, which shows the numbers in each cell. Then the game play will be easy. And I'll finally have the new feature I talked about in my earlier article.
The new code isn't yet live at kakuro-master.com, but as soon as I get something to generate new board layouts, I'll switch to the new Elm version, and put "Elm inside", at the bottom of the page, with a small version of the logo above.
If you want to look at my code in progress, it's at github.com/billstclair/kakuro-master. And I tweet about it tagged with @myElmStatus.
Elm Rocks!
I renamed my game to "Kakuro Dojo", since "Kakuro Master" is already the name of a PC game that you can purchase at kakuro.com.
It's live and fully functional at Kakuro-Dojo.com.
The basic gameplay is done, error and completion display, display of remaining possibilities for the selected row and column, and hints to help you think about those possibilities.
I'm working today on saving your state in your browser, including the board where you're at for every game you've played. Then I'll write some server code, and give you the option of saving your state on the server, so it will be available from another browser.
And then I'll work on my new feature, automating trial guesses. You're not supposed to have to do that to beat a Kakuro puzzle, but that's not my experience with the harder puzzles I've played. Hints don't quite get you there.
Finally, I'll wrap it as iTunes and Android apps.