I'm sure it's very clever, but the result (<a href="http://tonyday567.github.io/static/index-auto.html" rel="nofollow">http://tonyday567.github.io/static/index-auto.html</a>) didn't work for me in Chrome (but did in Firefox). I suppose the unfortunate problem with this is that delivering it with an issue like that would mean that approximately 99.99% of the web developers out there would have no idea how to fix it (the generated JS is utterly incomprehensible, of course).
I'm a big fan of static typing, including sum types. But can someone explain to me what's so great here?<p>The highlight of the article is having a unique Action sum type instead of a myriad of separate functions. But the action still has to be processed by a myriad of separate equations (is that the correct Haskell term? Not familiar with the language):<p><pre><code> apply ClearCompleted tds = over todosItems (Map.filter (\x -> view itemStatus x /= Completed)) tds
apply (DeleteItem x) tds = over todosItems (Map.delete x) tds
apply (EditItem x) tds = set todosEditing (Just x) tds
...
</code></pre>
"Only one of the 68 frameworks defined an Action" is probably because it's simpler to directly call the right function, rather than over-engineering things with a short-lived intermediary representation.<p>If actions need to "be serialized, recorded for later analytics, and generated automatically" then it makes much more sense. But this is a TODO sample app. YAGNI.<p>And if we really need it, it's not like JS cannot do it:<p><pre><code> function apply(action, todos) {
switch (action.type) {
case 'ClearCompleted':
return todos.filter(todo => !todo.completed);
case 'DeleteItem':
return todos.filter(todo => todo !== action.todo);
...
}
}
</code></pre>
The above has probably been done a billion times in one form or another. Of course it's not safe from typos in the case strings or missing cases, but that's a broader issue with JS in general, not specifically related to sum types.<p>I'm not trying to shoot down Haskell here, I really wish someone will point to something I'm missing and make it click. But right now it just looks like over-engineering that JS <i>could</i> do but <i>chooses</i> not to.<p>(Regarding footnote #4: Swift also has sum types and is fairly popular.)
Yikes, 1,670KB for generated javascript alone, that's kind of a deal breaker.<p>GHCJS has a ways to go methinks. Js_of_ocaml and Scala.js are far better suited for production use today as the type safety "tax" is much smaller (i.e. binary is at most 1/4 the size for equivalent functionality).<p>EDIT:<p>didn't realize you cannot yet call into Haskell from GHCJS, and even Haskell to GHCJS requires going through FFI[1]<p>Meh, might as well use Fay or Haste if that's the caste.<p>[1] <a href="http://stackoverflow.com/questions/29967135/how-to-call-haskell-from-javascript-with-ghcjs" rel="nofollow">http://stackoverflow.com/questions/29967135/how-to-call-hask...</a>
Github link is broken .org instead of .com <a href="https://github.com/tonyday567/mvc-todo" rel="nofollow">https://github.com/tonyday567/mvc-todo</a>
"It’s going to become much harder for haskell to avoid success"<p>I have 100% faith in the Haskell community's ability to keep doing what they've been doing for years. ;)
I start to like Haskell and would enjoy learning to use it for the Web, but look at the size of it:<p><a href="http://i.imgur.com/kPHl4L7.png" rel="nofollow">http://i.imgur.com/kPHl4L7.png</a><p>7834KB is way too large for just that, I'm afraid.<p>I've 120Mbit/s, that's why it still loads fast, but I remember how slow, but fascinating surfing with 56K modem was.