TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Haskell as a JavaScript MVC framework

55 pointsby zygomegaalmost 10 years ago

7 comments

bshimminalmost 10 years ago
I&#x27;m sure it&#x27;s very clever, but the result (<a href="http:&#x2F;&#x2F;tonyday567.github.io&#x2F;static&#x2F;index-auto.html" rel="nofollow">http:&#x2F;&#x2F;tonyday567.github.io&#x2F;static&#x2F;index-auto.html</a>) didn&#x27;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).
评论 #9592414 未加载
ciesalmost 10 years ago
Good article, I really like the insight of how sum types can be used in MVC, and how the OO community is oblivious of this.<p>Nice short read.
peferronalmost 10 years ago
I&#x27;m a big fan of static typing, including sum types. But can someone explain to me what&#x27;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 -&gt; view itemStatus x &#x2F;= Completed)) tds apply (DeleteItem x) tds = over todosItems (Map.delete x) tds apply (EditItem x) tds = set todosEditing (Just x) tds ... </code></pre> &quot;Only one of the 68 frameworks defined an Action&quot; is probably because it&#x27;s simpler to directly call the right function, rather than over-engineering things with a short-lived intermediary representation.<p>If actions need to &quot;be serialized, recorded for later analytics, and generated automatically&quot; then it makes much more sense. But this is a TODO sample app. YAGNI.<p>And if we really need it, it&#x27;s not like JS cannot do it:<p><pre><code> function apply(action, todos) { switch (action.type) { case &#x27;ClearCompleted&#x27;: return todos.filter(todo =&gt; !todo.completed); case &#x27;DeleteItem&#x27;: return todos.filter(todo =&gt; todo !== action.todo); ... } } </code></pre> The above has probably been done a billion times in one form or another. Of course it&#x27;s not safe from typos in the case strings or missing cases, but that&#x27;s a broader issue with JS in general, not specifically related to sum types.<p>I&#x27;m not trying to shoot down Haskell here, I really wish someone will point to something I&#x27;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.)
评论 #9592742 未加载
评论 #9594737 未加载
评论 #9592949 未加载
评论 #9592802 未加载
评论 #9601842 未加载
virtualwhysalmost 10 years ago
Yikes, 1,670KB for generated javascript alone, that&#x27;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 &quot;tax&quot; is much smaller (i.e. binary is at most 1&#x2F;4 the size for equivalent functionality).<p>EDIT:<p>didn&#x27;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&#x27;s the caste.<p>[1] <a href="http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;29967135&#x2F;how-to-call-haskell-from-javascript-with-ghcjs" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;29967135&#x2F;how-to-call-hask...</a>
评论 #9593262 未加载
Detrusalmost 10 years ago
Github link is broken .org instead of .com <a href="https:&#x2F;&#x2F;github.com&#x2F;tonyday567&#x2F;mvc-todo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tonyday567&#x2F;mvc-todo</a>
评论 #9592495 未加载
al2o3cralmost 10 years ago
&quot;It’s going to become much harder for haskell to avoid success&quot;<p>I have 100% faith in the Haskell community&#x27;s ability to keep doing what they&#x27;ve been doing for years. ;)
FractalNervealmost 10 years ago
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:&#x2F;&#x2F;i.imgur.com&#x2F;kPHl4L7.png" rel="nofollow">http:&#x2F;&#x2F;i.imgur.com&#x2F;kPHl4L7.png</a><p>7834KB is way too large for just that, I&#x27;m afraid.<p>I&#x27;ve 120Mbit&#x2F;s, that&#x27;s why it still loads fast, but I remember how slow, but fascinating surfing with 56K modem was.
评论 #9593152 未加载