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.

{-# Language QualifiedDo #-}

import qualified Data.Forced as DF
import Data.Forced hiding (pure, fmap, (\<*\>), return, (>>=), (>>))
import Data.Map.Lazy qualified as ML

noThunksForWHNF :: IO ()
noThunksForWHNF = do
  -- map0 actually evaluated on here.
  let map0 :: Demand (ML.Map Char (ForcedWHNF Int))
      map0 =
        v <- demandWHNF (const (2 + 2) 'a')
        DF.pure $ ML.insert 'a' v ML.empty

  map1 <- extractDemand map0
  go (ML.lookup 'a' map1)

-- pattern matching for de-structuring, no construction allowed.
go :: ForcedWHNF Int -> IO ()
go (ForcedWHNF i) =  print i


[Index] [Quick Jump]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,
Change log
Dependencies base (>= && <4.20.0), data-elevator (>=, deepseq (>= [details]
License MIT
Copyright 2023
Author Ruben Astudillo
Revised Revision 1 made by RubenAstudillo at 2024-01-31T01:02:51Z
Category Data
Home page
Bug tracker
Source repo head: git clone
Uploaded by RubenAstudillo at 2023-04-25T02:47:44Z
Downloads 125 total (9 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]