S
Simon Marlow
simonmar.github.io · Personal blog · on HN since 2015
Simon Marlow, a Haskell compiler and runtime developer, writes about GHC, concurrency, and Haskell at scale.
What HN saysHN commenters recommend his book on parallel and concurrent Haskell, and cite his work on GHC's scheduler and Safe Haskell.
30HN people shared it
16linked it in comments
16stories submitted
815story points
8 months agolast shared
2015people per year2026
Most-shared posts
- 1Hotswapping Haskell4 people · 151 points · first shared 2017 · 34 comments on HN
- 2Pcph4 people · first shared 2019
- 3Stack traces in GHCi, coming in GHC 8.0.13 people · 156 points · first shared 2016 · 2 comments on HN
- 4Asynchronous Exceptions in Practice3 people · 120 points · first shared 2017 · 9 comments on HN
- 5Haxl icfp14.pdf3 people · first shared 2019
- 6Haskell in the Datacentre2 people · 276 points · first shared 2016 · 43 comments on HN
- 7Rethinking Static Reference Tables in GHC2 people · 71 points · first shared 2018 · 9 comments on HN
- 8Parallel gc.pdf2 people · first shared 2017
- 9Optimising Garbage Collection Overhead in Sigma1 people · 33 points · first shared 2015 · 4 comments on HN
- 10Haskell on a Shared-Memory Multiprocessor (2005) [pdf]1 people · 3 points · first shared 2022 · discussion on HN
- 11Indexing Hackage: Glean vs. Hiedb1 people · 3 points · first shared 2025 · discussion on HN
- 12Fun with Haxl (Part 1)1 people · 1 points · first shared 2015 · discussion on HN
- 13Haskell Positions at Facebook – Simon Marlow1 people · 1 points · first shared 2016 · discussion on HN
- 14Shake.pdf1 people · first shared 2021
- 15Eval apply.pdf1 people · first shared 2026
What HN people wrote when they linked it
eklavya · 2022-08-12
This is oft overlooked, Haskell is absolutely in a league of its own when it comes to concurrency and parallel capabilities.
I would highly recommend https://simonmar.github.io/pages/pcph.html regardless of which language you use day to day. It a treasure trove of excellent information.
mbrock · 2019-06-06
The Haskell philosophy is easily misunderstood. It's not really that shared mutable state is evil but that it's difficult and so should be treated seriously and explicitly. The language still supports it—quite well. GHC's green thread scheduler is top-shelf. The main author of the GHC runtime wrote an excellent O'Reilly book called "Parallel and Concurrent Programming in Haskell" (which you can read for free online).
https://simonmar.github.io/pages/pcph.html
Of course that's not to say that Haskell is optimal for your work in embedded systems!
internet_points · 2026-03-13
Drawn in by the Emacs, learnt something new about C and C++, thank you for this! Very readable article for someone who doesn't feel too confident with low-level bits.
Btw, is this representation the reason why OCaml's ints are not as big as C ints?
Also interesting that the Haskell pointer tagging you link to[0] was done the way it was to avoid CPU branch misprediction, and that the old way which it replaced was "the source of half of the branch misprediction events". I wonder how "branch prediction friendly" current Haskell is.
[0] https://simonmar.github.io/bib/papers/ptr-tagging.pdf
armchairhacker · 2024-09-14
Haskell has a “safe” language dialect which prevents `unsafePerformIO` and others: https://downloads.haskell.org/~ghc/7.8.3/docs/html/users_guide/safe-ha… / https://simonmar.github.io/bib/papers/safe-haskell.pdf
However, I doubt Safe Haskell (without extensions) is formally verified, and it still uses GHC’s runtime, which could have RCEs. Also note that it doesn’t prevent infinite loops or memory exhaustion, the latter even during compilation.
iso8859-1 · 2024-08-14
Parallel and Concurrent Programming in Haskell
https://simonmar.github.io/pages/pcph.html
eru · 2023-04-14
Interesting. I wonder if it allows adding dependencies at runtime? (As explained in eg http://simonmar.github.io/bib/papers/shake.pdf )
cogman10 · 2021-03-23
If you're interested in a fun read, they've published a paper on how they do garbage collection.
http://simonmar.github.io/bib/papers/parallel-gc.pdf
pjmlp · 2020-02-09
Simon Marlow's book is also good source of information
"Parallel and Concurrent Programming in Haskell"
https://simonmar.github.io/pages/pcph.html
He also has some interesting articles like
https://simonmar.github.io/posts/2018-06-20-Finding-fixing-space-leaks…
pka · 2019-07-23
For completeness' sake, Haskell has had this for over a decade :) A SO thread that gives a nice overview [0], the paper [1], the library [2]. Here's how a parallel fib looks like:
fib :: Int -> Int
fib n
| n <= 1 = 1
| otherwise = x ‘par‘ (y ‘pseq‘ x + y + 1)
where
x = fib (n-1)
y = fib (n-2)
[0] https://stackoverflow.com/questions/958449/what-is-a-spark-in-haskell
[1] http://simonmar.github.io/bib/papers/strategies.pdf
[2] http://hackage.haskell.org/package/parallel-3.2.2.0/docs/Control-Paral…
edwintorok · 2019-07-16
Applicative Functors/Selective Applicative Functors should be more suitable to serialization than monads, because they do not contain lambdas and expose the underlying structure, allowing you to inspect,modify it, etc.:
https://www.cs.ox.ac.uk/jeremy.gibbons/publications/delivery.pdf
http://simonmar.github.io/bib/papers/haxl-icfp14.pdf
https://www.staff.ncl.ac.uk/andrey.mokhov/selective-functors.pdf
gregwebs · 2019-04-24
Haskell (a compiled lanaguage) has done hot code reloading with ghci for a long time. Facebook actually deploys in production by reloading. https://simonmar.github.io/posts/2017-10-17-hotswapping-haskell.html
ashika · 2018-12-19
>By introducing a second layer of scheduling, the M-to-N model makes performance tuning to the
model exceedingly difficult.
Reminds me of Simon Marlow's work[1] on tuning the Haskell runtime for a specific use at fb.
[1] https://simonmar.github.io/posts/2016-12-08-Haskell-in-the-datacentre.…
hajile · 2017-03-16
Haskell's garbage collector is compacting (see below). When the GC compacts, it is very easy to put linked list entries together for more efficient access.
http://simonmar.github.io/bib/papers/parallel-gc.pdf
danidiaz · 2016-02-20
A workaround for long compile times is trying to stay withing GHCi whenever possible and reload from there.
http://chrisdone.com/posts/haskell-repl
http://chrisdone.com/posts/making-ghci-fast
The Haxl team seem to use this strategy:
"Haxl users at Facebook do a lot of development and testing inside GHCi. In fact, we’ve built a customized version of GHCi that runs code in our Haxl monad by default instead of the IO monad, and has a handful of extra commands to support common workflows needed by our developers."
http://simonmar.github.io/posts/2016-02-12-Stack-traces-in-GHCi.html
drathier · 2026-03-22
1. Such bad examples :( Tuples are data types you have to destruct, in every language. Somebody please show me a language where this doesn't require a tuple-to-function-argument translation:
sayHi name age = "Hi I'm " ++ name ++ " and I'm " ++ show age
people = [("Alice", 70), ("Bob", 30), ("Charlotte", 40)]
-- ERROR: sayHi is String -> Int -> String, a person is (String, Int)
conversation = intercalate "\n" (map sayHi people)
In python you have `*people` to destruct the tuple into separate arguments, or pattern matching. In C-languages you have structs you have to destruct.
2. And performance, you'd think a slow-down affecting every single function call would be high-up on the optimization wish list, right? That's why it's implemented in basically every compiler, including non-fp compilers. Here's GHC authors in 2004 declaring that obviously the optimization is in "any decent compiler". https://simonmar.github.io/bib/papers/eval-apply.pdf
3. Type errors, the only place where currying is actually bad, is not even mentioned directly. Accidentally passing a different number of arguments compared to what you expected will result in a compiler error.
Some very powerful and generic languages will happily support lots of weird code you throw at them instead of erroring out. Others will errors out on things you'd expect them to handle just fine.
Here's Haskell supporting something most people would never want to use, giving it a proper type, and causing a confusing…
Twisol · 2020-10-25
> You still have to pass your logging code to every function that does logging right?
Yes, but no. Again, there are functional patterns you can apply.
First, functional programs tend to be more horizontally composed than vertically. Side effects usually happen at the same "level" of the application, rather than occuring at multiple depths. So the need to thread logging apparati is already reduced, simply because logging only happens higher up in the application.
Second, because side-effects only really occur at this thin layer, you can capture logging as a monadic action, avoiding the need to explicitly thread the logger state around. (This is the same situation as the "thread the world" problem we discussed earlier.)
Third, because so much more of your program is pure, it is much easier to perform unit tests and check assertions in other ways. At that level, logging is a bandaid over poor testing and assurance, not a goal in itself.
Finally, if you do find yourself deep down-stack with a need to perform some kind of side-effect, you can apply logical methods (a la LVars, CRDTs) to give a stateful interaction between separated parts of your program. The Haxl paper [0] is a good example of this: most of the design is pure functional, but for the part that involve an interaction not easily captured by the fundamental call-return / request-response pattern, they utilize monotonic state to maintain a registry of fulfilled and unfulfilled requests.
[0]…