DeepSeq +Control

module Control.DeepSeq
deepseq Control.DeepSeq
This module provides an overloaded function, deepseq, for fully evaluating data structures (that is, evaluating to "Normal Form"). A typical use is to prevent resource leaks in lazy IO programs, by forcing all characters from a file to be read. For example: > import System.IO > import Control.DeepSeq > > main = do > h <- openFile "f" ReadMode > s <- hGetContents h > s `deepseq` hClose h > return s deepseq differs from seq as it traverses data structures deeply, for example, seq will evaluate only to the first constructor in the list: > > [1,2,undefined] `seq` 3 > 3 While deepseq will force evaluation of all the list elements: > > [1,2,undefined] `deepseq` 3 > *** Exception: Prelude.undefined Another common use is to ensure any exceptions hidden within lazy fields of a data structure do not leak outside the scope of the exception handler, or to force evaluation of a data structure in one thread, before passing to another thread (preventing work moving to the wrong threads).
deepseq :: NFData a => a -> b -> b
deepseq Control.DeepSeq
deepseq: fully evaluates the first argument, before returning the second. The name deepseq is used to illustrate the relationship to seq: evaluates the top level of its argument, deepseq traverses the entire data structure evaluating it completely. deepseq can be useful for forcing pending exceptions, eradicating space leaks, or forcing lazy I/O to happen. It is also useful in conjunction with parallel Strategies (see the parallel package). There is no guarantee about the ordering of evaluation. The implementation may evaluate the components of the structure in any order or in parallel. To impose an actual order on evaluation, use pseq from Control.Parallel in the parallel package.
package deepseq
package
This package provides methods for fully evaluating data structures (&quot;deep evaluation&quot;). Deep evaluation is often used for adding strictness to a program, e.g. in order to force pending exceptions, remove space leaks, or force lazy I/O to happen. It is also useful in parallel programs, to ensure pending work does not migrate to the wrong thread. The primary use of this package is via the deepseq function, a &quot;deep&quot; version of seq. It is implemented on top of an NFData typeclass (&quot;Normal Form Data&quot;, data structures with no unevaluated components) which defines strategies for fully evaluating different data types. If you want to automatically derive NFData instances via the GHC.Generics facility, there is a companion package <http:hackage.haskell.orgpackagedeepseq-generics deepseq-generics> which builds on top of this package. Version 1.3.0.2
package deepseq-generics
package
This package provides a GHC.Generics-based Control.DeepSeq.Generics.genericRnf function which can be used for providing a rnf implementation. See the documentation for the genericRnf function in the Control.DeepSeq.Generics module to get started. The original idea was pioneered in the generic-deepseq package (see http://www.haskell.org/pipermail/haskell-cafe/2012-February/099551.html for more information). This package differs from the generic-deepseq package by working in combination with the existing deepseq package as opposed to defining a conflicting drop-in replacement for deepseq's Control.Deepseq module. Version 0.1.1.1
package deepseq-th
package
This package provides a Template Haskell based mechanism for deriving optimised NFData instances for custom data types. See documentation in Control.DeepSeq.TH for more information. See also the deepseq-generics package (http://hackage.haskell.org/package/deepseq-generics) for a less experimental approach. Version 0.1.0.4
package containers-deepseq
package
package generic-deepseq
package
This package provides a deepseq function analogous to seq, except that it traverses the entire data structure, evaluating it fully, and not just up to head normal form. Using lists as an example: > > [1,2,undefined] `seq` 3 > 3 Whereas with deepseq: > > [1,2,undefined] `deepseq` 3 > *** Exception: Prelude.undefined Unlike the deepseq package, this implementation is based on the GHC.Generics framework as found in GHC >= 7.2, so that it can generate instances automatically for any datatype that has a Generic instance, without further code. > data MyType = MyType String Int (Maybe Double) > deriving Generic > instance DeepSeq MyType Changes in version 2.0.0.0: * Vastly improved performance. As a consequence of these changes, the member function of the DeepSeq class is now rnf, instead of deepseq. * New instances for functions, Ratio and Complex types. Changes in version 2.0.1.0: * Fix the U1 and V1 instances. Changes in version 2.0.1.1: * No functional changes, updated to correct the URLs of the repository and the issue tracker. Version 2.0.1.1
rdeepseq :: NFData a => Strategy a
parallel Control.Parallel.Strategies
rdeepseq fully evaluates its argument. > rdeepseq == evalSeq Control.Seq.rdeepseq
rdeepseq :: NFData a => Strategy a
parallel Control.Seq
rdeepseq fully evaluates its argument. Relies on class NFData from module Control.DeepSeq.