Todo done?

Posted on March 15, 2015

Well, not entirely, but I now have a version of the todo app that runs on this stack (for which I’d like to think of a groovy name):

Yesod
GHCJS
reactive-banana
jQuery

It’s backed by the same REST API that the Ember implementation foisted upon me, so it’s reasonably plausible. Currently, this is all entwined with flare itself. My very next step is to extricate it into its own package.

Then I want to look at the fundamental data type. The Yesod model gives us the type Todo (without an id field), and the type Entity Todo which pairs a Todo with an id. This is serialized into a flat JSON type, obviously including the id field:

{"todos":[{"isCompleted":false,"id":65,"title":"this"},{"isCompleted":false,"id":67,"title":"the other"},{"isCompleted":false,"id":68,"title":"something else"}]}

This is all fairly reasonable, (and in any case I’m almost sure that the toJSON instance for Entity came from the Yesod scaffolding, so I don’t want to change it). The problem is that on the GHCJS side, I am deserializing to a different type, let’s call it TodoId, that does include the id field. The obvious thing to do is to use Entity on the GHCJS side too. This should remove a wart in the implementation: when we are creating a new todo item, we cannot use TodoId as we don’t have an id field yet.

Other things to look at:

  1. use shake to build both sides of the app;
  2. error handling;
  3. startup time.