Haskell as a JavaScript MVC framework
tonyday567.github.io
Haskell as a JavaScript MVC framework
1–10 of 26 posts
Re: Haskell as a JavaScript MVC framework
#2Re: Haskell as a JavaScript MVC framework
#3Re: Haskell as a JavaScript MVC framework
#4I'm sure it's very clever, but the result ( http://tonyday567.github.io/static/index-auto.html ) 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 think, that if you could integrate source-map capabilities (haven't tried http://hackage.haskell.org/package/sourcemap yet) it might make the debug process more bearable.
But if you would be looking for haskell-like-language with more comprehensible to-javascript output, http://www.purescript.org/ pleasantly suprised me (even though I had time to barely get past the hello world :-)
Re: Haskell as a JavaScript MVC framework
#5Github link is broken .org instead of .com https://github.com/tonyday567/mvc-todo
https://github.com/tonyday567/mvc-todo/tree/master/library/T...
Re: Haskell as a JavaScript MVC framework
#6Github link is broken .org instead of .com https://github.com/tonyday567/mvc-todo
I did not even find the GitHub link... This brings you straight to the meat of the project: https://github.com/tonyday567/mvc-todo/tree/master/library/T...
https://github.com/tonyday567/mvc-todo/blob/cb4bbb613aa31ba6...
Re: Haskell as a JavaScript MVC framework
#7Nice short read.
Re: Haskell as a JavaScript MVC framework
#8The 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):
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
...
"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.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.
And if we really need it, it's not like JS cannot do it:
function apply(action, todos) {
switch (action.type) {
case 'ClearCompleted':
return todos.filter(todo => !todo.completed);
case 'DeleteItem':
return todos.filter(todo => todo !== action.todo);
...
}
}
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.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 could do but chooses not to.
(Regarding footnote #4: Swift also has sum types and is fairly popular.)
Re: Haskell as a JavaScript MVC framework
#9I'm a big fan of static typing, including sum types. But can someone explain to me what's so great here? 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): apply ClearCompleted tds = over todosItems (Map.filter (\x -> vie…
Re: Haskell as a JavaScript MVC framework
#10GHCJS 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).
EDIT:
didn't realize you cannot yet call into Haskell from GHCJS, and even Haskell to GHCJS requires going through FFI[1]
Meh, might as well use Fay or Haste if that's the caste.
[1] http://stackoverflow.com/questions/29967135/how-to-call-hask...