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 Primitives

72 pointsby LukeHoerstenabout 10 years ago

6 comments

LukeHoerstenabout 10 years ago
SPJ, co-author of GHC, added this awesome comment:<p>&quot;&quot;Look at the implementation of other functions in GHC.Prim;they&#x27;re all defined as let x = x in x.&quot;<p>This begs the question of why this strange code exists at all. Answer: the sole reason is to give Haddock documentation for the primops a place to live. GHC.Prim is processed by Haddock more or less like any other module; but is effectively ignored by GHC itself.<p>Worth saying this.<p>Simon&quot;
评论 #9179671 未加载
LukeHoerstenabout 10 years ago
This is one of my favorite innards-of-Haskell articles. It&#x27;s such an intuitive way to look at how a super high level language like Haskell gets down to machine primitives. So important for optimization too.<p>I&#x27;ve been in HFT for a while and what strikes me is the performance optimizations you make in C++, Java, and Haskell are actually so so similar. Get down to the primitives. Avoid boxing. Avoid memory allocation at run time. Makes me think any language can be performant if you know what you&#x27;re doing.
评论 #9179986 未加载
jpt4about 10 years ago
&quot;When GHC reaches a call to one of these primops, it automatically replaces it with the real implementation for you, which will be some assembly code, LLVM code, or something similar.&quot;<p>This, plus the &quot;magic hashes&quot; reminds me a great deal of Urbit&#x27;s hinting syntax for jet propulsion (associating a body of high-level code in Hoon with an alternative (presumably low-level) implementation).
wyagerabout 10 years ago
Cool article! Very in-depth.
fspeechabout 10 years ago
Since Haskell is lazy, how does packaging io into a chain of function calls guarantee ordering? Does it depend on some primitives being strict?
评论 #9180953 未加载
FullyFunctionalabout 10 years ago
Why this intentional misleading title?
评论 #9179634 未加载