The latest version of data-forced is 0.3.0.0-1.

data-forced

Version 0.1.0.0 revision 0 uploaded by RubenAstudillo.

Package meta

Synopsis
Specify that lifted values were forced to WHNF or NF.
Description

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
Author
Ruben Astudillo
Bug reports
n/a
Category
Data
Copyright
2023
Homepage
n/a
Maintainer
ruben.astud@gmail.com
Package URL
n/a
Stability
n/a

Components