Spawn threads that never die (unless told to do so)

Version on this page:
LTS Haskell 15.14:0.3
Stackage Nightly 2020-05-26:0.3
Latest on Hackage:0.3

See all snapshots immortal appears in

MIT licensed by Roman Cheplyaka
Maintained by [email protected]

Module documentation for

This version can be pinned in stack with:[email protected]:df0066ff0de045bfe10bc13f85af33dcf9043d56bf70f5c943f45f0fbbde6f0c,1414


A small library to create threads that never die. This is useful e.g. for writing servers.

import qualified Control.Immortal as Immortal
import Control.Concurrent (threadDelay)
import Control.Monad (forever)

main = do
  -- start an immortal thread
  _thread <- Immortal.create $ \ _thread -> do
    -- do stuff

  -- in the main thread, sleep until interrupted
  -- (e.g. with Ctrl-C)
  forever $ threadDelay maxBound




Fix the README

Version 0.2.2

Add onUnexpectedFinish

Version 0.2.1

Add wait and wait-stm functions

Version 0.2

  • Pass a Thread handle to the thread itself
  • Add mortalize, immortalize