Copyright | (c) 2014, Andrew G. Seniuk |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Andrew Seniuk <rasfar@gmail.com> |
Stability | provisional |
Portability | portable (but GHC for a few modules using generics) |
Safe Haskell | None |
Language | Haskell2010 |
We provide forcing functions which take a non-strict value
of a datatype, and force its evaluation in a pricipled way.
As with NFData
, one should bear in mind the difference
between forcing and demand: in order for your forcing to
take effect, demand must be placed on the forcing function
itself by the course of execution.
A typical use of bounded forcing is to prevent resource leaks in lazy streaming, by forcing chunks of data of bounded but sufficient depth for the consumer to make progress.
Another use is to ensure any exceptions hidden within lazy fields of a data structure do not leak outside the scope of the exception handler; another is to force evaluation of a data structure in one thread, before passing it to another thread (preventing work moving to the wrong threads). Unlike DeepSeq, potentially infinite coinductive data types are supported by principled bounding of deep evaluation.
Refer to comments in the deepseq
package for more information on how
artificial forcing can be useful.
Recently, control (static or dynamic) of parallelisation has been added.
Control of evaluation order should also be possible (using pseq
).
- module Control.DeepSeq.Bounded.NFDataN
- module Control.DeepSeq.Bounded.Pattern
- module Control.DeepSeq.Bounded.PatAlg
- module Control.DeepSeq.Bounded.NFDataP
- module Control.DeepSeq.Bounded.NFDataPDyn
- data Rose a = Node a [Rose a]
- module Control.DeepSeq.Bounded.Generics.GSeqable
- module Control.DeepSeq.Bounded.Generics.GNFDataN
- module Control.DeepSeq.Bounded.Generics.GNFDataP
- module Control.DeepSeq.Bounded.Seqable
- module Control.DeepSeq
Forced evaluation to an arbitrary finite depth
Forced evaluation over a pattern (arbitrary finite, or dynamic)
Generic deriving support via Generics.SOP
Forced evaluation "molecular style"
Re-exported
module Control.DeepSeq