@hackage deepseq-bounded0.5.2

Bounded deepseq, including support for generic deriving

  • Installation

  • Dependencies (8)

  • Dependents (3)

    @hackage/seqaid, @hackage/acme-everything, @hackage/leaky
  • Package Flags

      haskell98_fragment
       (off by default)

      Sacrifice generic deriving, the NFDataPDyn module, and a couple functions from the PatAlg module, in exchange for true Haskell98 conformance (portability). You need to set PARALLELISM_EXPERIMENT, USE_WW_DEEPSEQ, USE_SOP, and NFDATA_INSTANCE_PATTERN to False if you set HASKELL98_FRAGMENT to True. (One thing it insists on is -XPatternGuards, although this could be relieved in the obvious way...)

      parallelism_experiment
       (on by default)

      We can selectively use par instead of seq, which is interesting.

      just_alias_gseqable
       (on by default)

      The SOP generic function is probably more performant, anyway! (This will be forced False if HASKELL98_FRAGMENT is True.)

      use_ww_deepseq
       (on by default)

      Depend on deepseq and deepseq-generics, to provide conditional deep forcing. This is optional.

      warn_pattern_match_failure
       (off by default)

      For NFDataP, if a pattern match fails a warning is output to stderr.

      use_sop
       (on by default)

      Use the generics-sop package instead of GHC.Generics (in GNFDataN) and instead of SYB (in NFDataPDyn). If USE_SOP is False, and NFDataPDyn, GNFDataP, and GSeqable modules will not be available. Also, if USE_SOP is False, then JUST_ALIAS_GSEQABLE must be False (this is not done for you; the language of Cabal flags makes it hard to write such logic, probably by design!...).

      nfdata_instance_pattern
       (on by default)

      A flag to assist debugging, affecting a few modules.

This package provides methods for partially (or fully) evaluating data structures ("bounded deep evaluation").

More information is available on the project homepage. There may be activity on this reddit discussion, where your comments are invited.

Quoting comments from the deepseq package:

"Artificial forcing is often used for adding strictness to a program, e.g. in order to force pending exceptions, remove space leaks, or force lazy IO to happen. It is also useful in parallel programs, to ensure work does not migrate to the wrong thread."

Sometimes we don't want to, or cannot, force all the way. Any infinite recursive type is an example. Also, bounded forcing bridges the theoretical axis between shallow seq and full deepseq.

We provide two new classes NFDataN and NFDataP. Instances of these provide bounded deep evaluation for arbitrary polytypic terms:

  • rnfn bounds the forced evaluation by depth of recursion.

  • rnfp forces based on patterns (static or dynamic).

Instances of NFDataN and NFDataP can be automatically derived via Generics.SOP, backed by the GNFDataN and GNFDataP modules.

Another approach is Seqable, which is similar to NFDataN, but optimised for use as a dynamically-reconfigurable forcing harness in the seqaid auto-instrumentation tool.

Recent developments supporting parallelisation control (in Pattern and Seqable modules) may justify renaming this library to something which emcompasses both strictness and parallelism aspects.