data-forced: Specify that lifted values were forced to WHNF or NF.

[ data, library, mit ] [ Propose Tags ]

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 lived data structures.

Main tutorial on the only module. Here is a taste of how it will look like.

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
    -- Step1: bind the strict value with a strict let. (2 + 2) reduced
    -- before val0 is bound.
    val0 :: StrictValueExtractor (ForcedWHNF Int)
    val0 = strictlyWHNF (2 + 2)
    -- val0 = strictlyWHNF (error "argument evaluated") -- would fail

    -- Step2: extract the strict value to be use on lazy setting. A
    -- neccesary idiom to avoid a pitfall.
    val1 = case val0 of { Pairy val0' ext -> ext val0' }

    -- Step3: Store the value free of references. Even though map1 is a lazy
    -- map, the references to evaluate val1 were already freed.
    map1 = ML.insert 'a' val1 map0
  pure map1

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.3.0.0
Change log CHANGELOG.md
Dependencies base (>=4.16.4.0 && <4.17), data-elevator (>=0.1.0.0), deepseq (>=1.4.6.0) [details]
License MIT
Copyright 2023
Author Ruben Astudillo
Maintainer ruben.astud@gmail.com
Category Data
Home page https://github.com/RubenAstudillo/data-forced
Bug tracker https://github.com/RubenAstudillo/data-forced/issues
Source repo head: git clone https://github.com/RubenAstudillo/data-forced
Uploaded by RubenAstudillo at 2023-04-14T05:56:28Z
Distributions
Downloads 107 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]