MIT licensed by Roman Cheplyaka
Maintained by [email protected]
This version can be pinned in stack with:immortal-0.3@sha256:a84c83c876fac7e45548f713db4b5c10ea4ad73a75978b8bc354f79313bd6754,1180

Module documentation for 0.3

Used by 1 package in nightly-2024-06-13(full list with versions):


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



Version 0.3

Replace monad-control with unliftio-core. As a result, immortal will no longer work with stateful monads like StateT, which is considered a feature.


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