Neodrop
Create
FeedDiscoverMy ChannelsAuto-publishJoin Our Discord
Neodrop
A smoother experience in the app
FeedDiscoverCreateMy Channels
What moves when the work moves: a distributed Haskell deep read
2026-11-02

What moves when the work moves: a distributed Haskell deep read

Robert Krook's survey of thirty years of distributed Haskell sorts seven systems by one question — what actually crosses the wire when work moves — and finds that shipping a graph of closures is the easy half.

Functional Programming Deep Dives
Functional Programming Deep Dives@Gidon Kaminer
Robert Krook published Distributed Haskell — A Survey on 26 October 2026. The post is the background chapter of his recently finished PhD thesis, edited to stand on its own. 1
Haskell Weekly put it first in issue 548 on 29 October. 2
The chapter works through seven systems, from GUM in 1996 to Unison, and one question runs through all of them: when work moves from one machine to another, what actually moves with it? 1
The data a computation needs is the easy half. The code that computes with it is the hard half, and each of the seven systems answers that difficulty in its own way. 1

Two aims, four questions

A distributed Haskell program is after one of two things. Either a single computation gets spread across cores or machines to finish sooner, or the application has parts that have to run near particular devices, data or services. 1
The first aim calls for distributed evaluation and the second for independently communicating components, so the programming models differ. The problems underneath them overlap enough that Krook treats both kinds of system in one survey. 1
Four questions go to every system. What are the independently executing units? Who decides where they run? What information can move between them? Which part of the language implementation supplies that mobility? 1
The fourth question is where the systems part company.

Part of the heap: GUM

GUM is a portable parallel implementation from 1996, built by Trinder and colleagues on top of the STG runtime. 1 The runtime gains a set of logical processing elements.
Each element keeps its own local heap and schedules its own pool of Haskell threads, and together the local heaps make up one global virtual heap holding the program's shared graph. 1
Placement in GUM stays implicit. One Haskell thread still drives the evaluation, and the runtime spreads work across the additional processing elements to speed that single computation up. 1
When evaluation on one element demands an object that another element owns, the owner packs more than the object.
It sends a bounded portion of the nearby reachable graph, which cuts the chance that a second request has to cross the network for the same neighbourhood. 1
Two tree-shaped graphs side by side, each beginning with a downward arrow labelled root. On the left, the arrow falls into a pair node, then two cons nodes, then four leaf boxes labelled #1, #2, #3 and #4 plus one labelled [], with an extra edge running from the lower cons node across to the [] box. On the right, the same upper structure, but its four leaves read #1, a red double-outlined box labelled FM, #3, and another red double-outlined box labelled FM.
Krook's two figures, (a) and (b), re-rendered from his vector originals and placed together. On the left is everything reachable from the requested root on the element that owns it. On the right is the bounded packet that actually crosses: both recursive list subgraphs stay behind, and the two edges that pointed into them end at Fetch-Me (FM) nodes.1
A Fetch-Me node is a placeholder that stands for a fragment left on the owning element. Demand it later and the runtime fetches the fragment it stands for. 1
What crosses is heap closures and the relationships between them. Every element already runs the same compiled program, so a closure only has to point at code that is installed there. 1

Threads and processes on distant machines

Glasgow Distributed Haskell, from 2000, kept GUM's multiple processing elements and adopted Concurrent Haskell's thread vocabulary. A program can list the elements, start a thread on one of them, and evaluate a value there: allPEId, rforkIO, revalIO. 1
Some resources have to stay where they are, so the Immobile type class exposes owningPE and a thread can ask which element holds one. 1 Concurrent Haskell's MVars were extended to work across elements and became the way threads on different ones exchanged data. 1
Eden, from 2005, names a function where Glasgow Distributed Haskell names a processing element.
A Process a b is a function from a to b that can be instantiated remotely; the # operator applies it, and the result arrives as a lazy placeholder that blocks until the process finishes. 1
Eden splits remote computation into three separate things: the ordinary Haskell function, the process wrapper made by process, and the instantiation performed by #. 1
Two constraints guard the boundary. Trans marks the types that may cross between processes, and NFData forces a value to be evaluated before it is communicated. 1
A process reaches its parent through a channel it gets for free. Any other destination needs a named channel made with new, and each of those channels can be written once; a second write raises an error. 1
Both systems still assume that every machine was provisioned with the same code in advance.

The first code that travels: mHaskell

Mobile Haskell, from 2003, is where the code itself starts to move. It extends Concurrent Haskell with MChannels, higher-order channels that carry values including functions, IO actions and other channels. 1
Channels register under a name that independently running programs can discover, which makes this an open system of peers. 1
Remote evaluation is one call: rforkIO :: IO () -> HostName -> IO () takes an IO action and starts it on the named host.
The action closes over whatever it captured, so mHaskell serialises the graph for that action, the captured values inside it, and the bytecode the action needs, then rebuilds the action on the other end. 1
Calls into native code, the ones behind putStrLn for instance, take a different route: they resolve against code already installed on the receiving machine. 1
That split is how mobility gets paid for. A module compiled by GHCi becomes a ByteCode Object that can travel inside a transmitted graph; a module compiled to native code cannot travel and has to be linkable at the destination.
The programmer chooses which modules go which way. 1
Serialisation begins with GUM's graph packing and then keeps going. The whole graph reachable from the transmitted value is serialised, with sharing and cycles preserved and no references left back into the sender's heap, so the receiver ends up with an independent copy. 1
What mHaskell asks for in return is a shared software base: compatible versions of its modified GHC runtime, the native libraries the bytecode calls, and compiled definitions of every user data type that is passed.
The prototype sends those values and leaves their definitions behind. 1
Krook points out what the design costs. mHaskell's implementation leans directly on GHC's internal representations of heap closures, ByteCode Objects and linker information, and that dependence is the price of building distribution inside a large, evolving compiler runtime. 1

The boundary moves into the type: Cloud Haskell

Cloud Haskell, from 2011, gets its distribution out of a library. It is a shallowly embedded domain-specific language over an ordinary GHC runtime, and it follows Erlang: lightweight processes with mailboxes, passing messages, with no shared memory. 1
A node is a runtime system at a network address. Each node runs many processes, each process has an identifier and a mailbox, and processes can spawn others locally or remotely and watch one another for termination. 1
Messages carry a type-level restriction, send and expect both require Serializable a. 1
Functions are where that restriction bites. A function's type gives its argument and its result, and says nothing about the environment it captured.
Two functions of type Int -> Int can have environments with entirely different serialisation needs, so whether a function can be serialised is unanswerable from its type. 1
Cloud Haskell's answer is the type Static a, with a typing rule drawn between top-level and local bindings.
An expression static e is accepted only when every free variable of e refers to a static top-level binding, which lets a static function be represented by a code label that every node resolves locally. 1
Remote spawning shows the boundary in a signature: spawn :: NodeId -> Closure (ProcessM ()) -> ProcessM ProcessId. The caller picks the node and hands over a Closure; a bare ProcessM () action fails to typecheck. 1
Krook is careful with the word closure. A Cloud Haskell Closure is a source-level Haskell value describing how to rebuild a value on another node, and it stands apart from the GHC heap closures in the GUM section. Its representation splits the two halves apart:
data Closure a where
  MkClosure :: Static (ByteString -> a) -> ByteString -> Closure a
The Static field names a reconstruction function that is installed on every node and has no hidden dynamic environment. The ByteString holds the environment, serialised at the construction site where its type is still known, because inside Closure a that type is gone. 1
Sending a function that captures a local variable therefore has to be written out by hand. The direct version passes \y -> x + y + 1 to send and does not compile, because Int -> Int identifies no code and reveals no x.
The version that compiles moves the body into a top-level function and decodes the environment inside it:
sendFunc :: ProcessId -> Int -> ProcessM ()
sendFunc p x = send p clo
  where
    clo :: Closure (Int -> Int)
    clo = MkClosure (static sfun) (encode x)

sfun :: ByteString -> Int -> Int
    sfun bs y = let x = decode bs in x + y + 1
That is closure conversion performed explicitly: the code becomes a top-level function, and the captured value becomes the serialised environment. Template Haskell generated the surrounding construction, decoding and registration, and the programmer still did the conversion. 1

One closure, two representations: HdpH

HdpH, also from 2011, keeps the static code references and aims at the other goal. It distributes tasks to speed a parallel computation up rather than describing processes that run independently. 1
The system builds on the Par monad, in which computations create parallel tasks and pass results through single-assignment variables called IVars. A piece of work available for parallel execution is a spark, the same word multicore GHC uses. 1
Placement is where the two kinds of spark differ. A GHC spark points at a closure in one runtime's shared heap; an HdpH spark is a serialisable closure that a scheduler can move to another node, and idle nodes take work from busy ones. 1
HdpH stores each closure twice, so that a spark which stays at home never pays to serialise its own environment:
data Closure a = UnsafeMkClosure a (Static (ByteString -> a)) ByteString
The first field is the live thunk, used when the closure is evaluated where it already sits. The other two are the static deserialiser and the serialised environment, used when the closure travels.
The constructor is unsafe because both representations have to describe the same computation and nothing checks that they do. 1
Keeping both forms also lets HdpH transform closures without serialising anything.
mapClosure :: Closure (a -> b) -> Closure a -> Closure b builds both representations of the result while asking a and b for no instances at all, which is what makes polymorphic evaluation strategies and algorithmic skeletons definable on top of the task interface. 1
HdpH communicates through IVars rather than mailboxes. An IVar is written once and a read blocks until the value arrives; a local IVar can be turned into a GIVar that a remote task writes with rput, and no operation reads a GIVar remotely. 1

Names replaced by hashes: Unison

Unison is the one system in the survey that is Haskell-inspired rather than Haskell: statically typed, purely functional, with a compiler written in Haskell. 1
Definitions in Unison are content-addressed. Each one is identified by a hash of its syntax tree, and that hash folds in the hashes of every definition it uses, so a name is metadata that the hash does not depend on. 3
That gives the system its way of moving code. The sender ships the bytecode tree of a computation; the recipient inspects it for hashes it lacks, requests the missing definitions from the sender, and caches them for later.
Krook draws the consequence: a node can run a computation it was never provisioned for in advance. 1

Where the seven systems land

Thirty years of systems split along one line.
GUM, Glasgow Distributed Haskell and Eden move work and data between machines that already run the same program.
Cloud Haskell and HdpH make the transferable computation an explicit value whose code half is a label resolving to code every node has.
mHaskell and Unison drop the shared-program assumption, mHaskell by carrying portable bytecode and Unison by fetching definitions by hash. 1
Read as a table, the seven answers line up:
SystemUnit of executionWhat may crossCode needed at the far end
GUMA Haskell thread on a logical processing elementHeap closures, a bounded subgraph, Fetch-Me placeholdersThe same compiled program on every element 1
Glasgow Distributed HaskellA Haskell thread started on a named elementClosures and MVarsThe same compiled program on every element 1
EdenA process, a function instantiated remotelyValues with a Trans instance, forced by NFDataThe same compiled program on every node 1
mHaskellAn IO action sent over a named channelA serialised graph carrying GHCi bytecodeA compatible patched GHC runtime, the native libraries, the data types used 1
Cloud HaskellA process with a mailboxMessages with a Serializable instance, and Closures of static code plus environmentThe same program on every node 1
HdpHA spark, a serialisable closureA static deserialiser and serialised environment, plus GIVar resultsThe same program on every node 1
UnisonA definition identified by hashDefinitions, fetched by hash on demandNothing specific to the application 1

Where Krook's own work sits

Krook places his own papers on the same axis. HasTEE assumes two locations, one of them a trusted execution environment.
The two sides compile and deploy separately and exchange serialised data, with code installed at deployment and data the only thing that moves. 1 The partitioning paper derives at compile time which code belongs at which endpoint. 1
CloudMicroHaskell takes the other route and moves the serialisation boundary out of the source-level API and into the MicroHs runtime.
MicroHs bytecode lets a process's code and its captured environment be serialised into one graph, and the only software every node shares is a compatible MicroHs runtime. 1
The move relocates error detection. Cloud Haskell rules out an unserialisable program at compile time; CloudMicroHaskell meets the same mistake when the process crosses a node boundary at run time. 1
Laziness then adds a cost that is easy to miss. A small value may be represented by a large, unevaluated graph, and that graph is what has to be serialised, transmitted and rebuilt. 1

What to take from it

  1. Decide what crosses, then pick the layer that checks it. Cloud Haskell enforces the decision in the type system with Serializable and Static; mHaskell and CloudMicroHaskell leave that check to run time, where the same mistakes surface later. The choice settles which errors a compiler can refuse for you.
  2. The environment is the part that needs writing down. A function's type hides what it captured, which is why Cloud Haskell's working example moves the body to a top-level sfun and serialises x beside it. Any language doing closure conversion by hand runs into the same job.
  3. Measure the graph rather than the value. Eden forces values with NFData before sending them; Krook's warning about laziness shows what happens without that step, since the size that crosses is the unevaluated graph and a small-looking value can carry a large one.
  4. Ask the four questions before the design is fixed. What is the unit, who places it, what may move, and which layer enforces that — the seven systems differ mainly in where they answer each one.

Verbatim quotes

"One problem runs through every system: when work moves from one machine to another, what actually moves?"
"GUM is important here because it demonstrates that a distributed runtime can move the state of a lazy computation by operating directly on its heap graph. It also exposes a central limitation that will recur throughout this post, that moving a graph of closures is not the same as moving the executable code to which those closures refer."
"Cloud Haskell therefore does not transmit executable code in the manner of mHaskell. It transmits a reference to installed code together with the data needed to reconstruct its environment."
"It is also invisible to the programmer precisely what the price of laziness is. A small value might be represented by a large, unevaluated graph, which will be more costly to serialise, transmit, and deserialise."
— Robert Krook, Distributed Haskell — A Survey

References

  1. 1
    Distributed Haskell — A Survey

    krook.dev

  2. 2
    Issue 548 :: Haskell Weekly Newsletter

    haskellweekly.news

  3. 3
    The big idea — Unison documentation

    unison-lang.org

Functional Programming Deep Dives
Functional Programming Deep Dives@Gidon Kaminer

This story was produced automatically by a channel. One sentence is all it takes for Neodrop to keep producing for you.

Related content

  • Two aims, four questions
  • Part of the heap: GUM
  • Threads and processes on distant machines
  • The first code that travels: mHaskell
  • The boundary moves into the type: Cloud Haskell
  • One closure, two representations: HdpH
  • Names replaced by hashes: Unison
  • Where the seven systems land
  • Where Krook's own work sits
  • What to take from it
  • Verbatim quotes