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 Is Exceptionally Unsafe

86 pointsby johndcookalmost 13 years ago

8 comments

jmillikinalmost 13 years ago
The author is complaining about two language extensions which are present in GHC. These extensions are not part of the Haskell language, which is defined at <a href="http://www.haskell.org/onlinereport/haskell2010/" rel="nofollow">http://www.haskell.org/onlinereport/haskell2010/</a> .<p>The first language extension is the function 'unsafePerformIO', defined in the module 'System.IO.Unsafe'. It's not defined in the language spec, and is unsafe <i>by design</i> because it's intended for very rare and specific use cases in performance-critical code.<p>The second language extension is the 'Data.Typeable' module, which defines a mechanism of dynamic typing. The standard way to use Typeable is to let the compiler define the instance, which is both safe and much easier to type. It's well-known that implementing a Typeable instance manually is unsafe; for example, see Oleg's post from 2007 <a href="http://okmij.org/ftp/Haskell/types.html#unsound-typeable" rel="nofollow">http://okmij.org/ftp/Haskell/types.html#unsound-typeable</a> .<p>Again, these are extensions to the language, implemented as experiments by a particular compiler. A program which uses them is no longer standard Haskell.<p>His code does not compile when built in standard Haskell mode:<p><pre><code> $ ghc --make exc.hs -hide-all-packages -package haskell2010 exc.hs:2:8: Could not find module `Data.Typeable'</code></pre>
评论 #4381501 未加载
评论 #4381334 未加载
评论 #4381354 未加载
评论 #4381540 未加载
jerfalmost 13 years ago
I suspect the reason why this is being upvoted and what it actually says have nothing to do with each other. This is a bit of an academic debate about very precise details of exception handling, not some sort of takedown of the Haskell hype.<p>In the event that you really are interested in the topic at hand, you probably ought to read the followups on <a href="http://www.reddit.com/r/haskell/comments/y74vn/robert_harper_haskell_is_exceptionally_unsafe/" rel="nofollow">http://www.reddit.com/r/haskell/comments/y74vn/robert_harper...</a> .
评论 #4381065 未加载
thirstehalmost 13 years ago
He should at least preface these kinds of posts with, or add something to the sidebar, that reveals that he is positively and absolutely biased toward SML: <a href="http://en.wikipedia.org/wiki/Robert_Harper_(computer_scientist)" rel="nofollow">http://en.wikipedia.org/wiki/Robert_Harper_(computer_scienti...</a><p>I get an odd taste in my mouth seeing a core language contributor bashing other languages for being "inferior," whilst attempting to appear neutral.
评论 #4381025 未加载
评论 #4381163 未加载
评论 #4381131 未加载
评论 #4381179 未加载
klodolphalmost 13 years ago
Hm, I was expecting this to at least mention that exceptions in Haskell pure code is imprecise, and you can only guarantee the exception you desire by throwing it in the IO monad.<p><a href="http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm" rel="nofollow">http://research.microsoft.com/en-us/um/people/simonpj/papers...</a><p>Although I'm not sure what the point is in the article: yes, if you write a purposefully flawed instance of Typeable, you will get errors when you try to use it. I'm not convinced that this is a demonstration that it is "unsafe", since the flawed Typeable instance seems to cause errors in the code that <i>uses</i> the flawed Typeable instance, and not in other parts of the code.
评论 #4381121 未加载
arsalmost 13 years ago
When he says "Exceptionally" does he mean "very much" or "relating to exceptions"? Or is it a pun and he means both?
评论 #4381400 未加载
评论 #4381406 未加载
评论 #4381391 未加载
eedahlgrenalmost 13 years ago
<a href="http://research.microsoft.com/en-us/um/people/simonpj/papers/safe-haskell/" rel="nofollow">http://research.microsoft.com/en-us/um/people/simonpj/papers...</a>
jcromartiealmost 13 years ago
Is this a troll? I can't tell...
评论 #4381437 未加载
peteretepalmost 13 years ago
NECK BEARD VS NECK BEARD<p>(this article appears to have no practical implications)
评论 #4382945 未加载