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.

Understanding the Elm type system

171 pointsby jaxondualmost 9 years ago

9 comments

spionalmost 9 years ago
&gt; For example, when writing an Elm program I might at some point decide that users should have an admin flag. I will then try to use that flag in a function at which point the compiler will tell me that I have failed to add it to the User model. I will add it to the model at which point the compiler will tell me that I have failed to account for it in my main update function.<p>This beautifully explains why types are so useful. I don&#x27;t know if the number of bugs goes down, but it sure is useful to have an assistant check <i>all</i> the implications of a change I want to make, and does that in a second.
评论 #11853255 未加载
评论 #11853285 未加载
z1mm32m4nalmost 9 years ago
It&#x27;s refreshing to see a piece written by someone who&#x27;s new to functional programming, discovering the beauty of types and pure functions for the first time.<p>I very much agree with the author; learning functional programming idioms have had a profound impact on my ability to model problems in code, regardless of the language I&#x27;m using.<p>I admire Elm so much for putting an emphasis on the user experience, recognizing that it has been one of the biggest blockers to making functional programming mainstream.
ghayesalmost 9 years ago
At first glance, Elm&#x27;s type system looks like it borrows heavily from Haskell [0]. Learning Haskell&#x27;s type system is a great mental exercise, even if you don&#x27;t even up coding in the language.<p>[0] Basics: <a href="http:&#x2F;&#x2F;learnyouahaskell.com&#x2F;types-and-typeclasses" rel="nofollow">http:&#x2F;&#x2F;learnyouahaskell.com&#x2F;types-and-typeclasses</a>
评论 #11852954 未加载
评论 #11853329 未加载
ralfdalmost 9 years ago
&gt; Elm was my introduction to using a static, strong type system.<p>I think I am now officially feeling old. A language I never heard of is the introduction to programmers to static typing??
评论 #11853384 未加载
评论 #11853584 未加载
captainmuonalmost 9 years ago
&gt; A big gotcha for me was understanding the -&gt; syntax. How can a function that accepts two arguments possibly have a type annotation like this?<p><pre><code> connectWords : String -&gt; String -&gt; String </code></pre> This is one of the most maddening things for me about Haskell-like languages. I can never remember if -&gt; is left or right associative. I mean there is only one way that makes sense:<p><pre><code> # String -&gt; (String -&gt; String) </code></pre> But it could also be<p><pre><code> # (String -&gt; String) -&gt; String </code></pre> Of course you get used to it after a while, but a nagging feeling remains. I would really prefer a bit of syntactic sugar.
评论 #11853826 未加载
评论 #11854285 未加载
lucioalmost 9 years ago
Honest question: How useful is that all functions are curried by default? Does this impose performance penalties?
评论 #11856950 未加载
mrkgnaoalmost 9 years ago
Does Elm not have typeclasses?<p>(I looked at the pics and saw `List.map` everywhere.)
评论 #11855051 未加载
评论 #11853688 未加载
warfanglealmost 9 years ago
Any suggestions on where to start with Elm?<p>Learn You an Elm examples don&#x27;t compile on the try-it-live console.<p>Official examples do, but fail to compile on a local install (after setting up elm package install etc).<p>Any suggestions on where to start troubleshooting?<p>It&#x27;s failing to find modules that are in the core standard lib.
评论 #11854179 未加载
lucioalmost 9 years ago
the elm debugger seems also impressive<p><a href="http:&#x2F;&#x2F;debug.elm-lang.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;debug.elm-lang.org&#x2F;</a>
评论 #11858473 未加载