@hackage data-forced0.1.0.0

Specify that lifted values were forced to WHNF or NF.

Alternative to bang patterns using CBV functions and unlifted data types. Tag your values to maintain the invariant that they were forced. Avoid liveness leaks on long running data structures.

import Data.Map.Lazy as ML -- Spine strict

-- No references on added leafs even though it is a lazy map.
basicEvent :: ML.Map Char (ForcedWHNF Int) -> IO (ML.Map Char (ForcedWHNF Int))
basicEvent map0 = do
  let val0 :: Strict (ForcedWHNF Int)
      -- val0 = strictlyWHNF (error "argument evaluated") -- would fail
      val0 = strictlyWHNF (2 + 2)
      -- CBV function, 2 + 2 reduced before val0 is bound.
      Strict val1 = val0  -- De-structure
      map1 = ML.insert 'a' val1 map0
  pure map1