packages feed

deepseq-bounded-0.5.0: deepseq-bounded.cabal

name:		deepseq-bounded
version:        0.5.0
synopsis:       Bounded deepseq, including support for generic deriving
homepage:       http://fremissant.net/deepseq-bounded
--homepage:       https://fremissant.com/deepseq-bounded
--bug-reports:    https://fremissant.com/deepseq-bounded/issues
license:	BSD3
license-file:	LICENSE
author:         Andrew G. Seniuk
maintainer:     andrew.seniuk@gmail.com
category:       Control
build-type:     Simple
cabal-version:  >=1.10
tested-with:    GHC==7.6.3, GHC==7.8.1, GHC==7.8.3
stability:      provisional
extra-source-files:     README
                      , test/*.hs
                      , HTML/*.html
                      , HTML/*.css
description:
    This package provides methods for partially (or fully) evaluating data
    structures (\"bounded deep evaluation\").
    .
    More information is available on the project <http://www.fremissant.net/deepseq-bounded homepage>.
    .
    Quoting comments from the
    <https://hackage.haskell.org/package/deepseq 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 I\/O 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 <https://hackage.haskell.org/package/seqaid 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.

--  "NFDataN" can optionally be derived by the standard "GHC.Generics"
--  facility (but not so for "NFDataP").

-- extra-source-files: changelog
-- 
-- source-repository head
--   type:     git
--   location: https://www.fremissant.com/package/deepseq-bounded.git
-- 
-- source-repository this
--   type:     git
--   location: https://www.fremissant.com/package/deepseq-bounded.git
--   tag:      deepseq-bounded-1.3.0.2-release

Flag HASKELL98_FRAGMENT
  Description: 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. (This was once up-to-date, but may have become in need of some attention. One thing it insists on is -XPatternGuards, although this could be relieved in the obvious way...)
--Default:     True
  Default:     False

Flag PARALLELISM_EXPERIMENT
  Description: We can selectively use par instead of seq, which is interesting.
  Default:     True
--Default:     False

-- Flag SEQUENTIALISM_EXPERIMENT
--   Description: We can selectively use pseq instead of seq, which is interesting. (This is more difficult to implement (usefully) than PARALLELISM_EXPERIMENT, and was left on hold for now.)
-- --Default:     True
--   Default:     False

Flag JUST_ALIAS_GSEQABLE
  Description: The SOP generic function is probably more performant, anyway! (This will be forced False if HASKELL98_FRAGMENT is True.)
  Default:     True
--Default:     False

Flag USE_WW_DEEPSEQ
  Description: Depend on deepseq and deepseq-generics, to provide conditional deep forcing. This is optional.
  Default:     True
--Default:     False

Flag WARN_PATTERN_MATCH_FAILURE
  Description: For NFDataP, if a pattern match fails a warning is output to stderr.
--Default:     True
  Default:     False

Flag USE_SOP
  Description: Use the generics-sop package instead of SYB for generics. NFDataPDyn and GNFDataP modules will not be available.
  Default:     True
--Default:     False

Flag NFDATA_INSTANCE_PATTERN
  Description: A flag to assist debugging, affecting a few modules.
  Default:     True
--Default:     False

library {

  hs-source-dirs: src

  -- This library is Haskell98 if you exclude the generics bits.
  -- See the comment below (other-extensions) for more specifics.
  if flag(HASKELL98_FRAGMENT)
    default-language: Haskell98
  else
    default-language: Haskell2010

  default-extensions:  CPP

-- If you exclude PatAlg.mkPat and PatAlg.growPat (which use SYB),
-- and NFDataPDyn, GNFDataN, and GNFDataP (which use GHC.Generics
-- and/or Generics.SOP), none of the code depends in any essential
-- way on language extensions. I use PatternGuards for convenience,
-- but they could be translated away easily, and we'd have Haskell98.
  if flag(HASKELL98_FRAGMENT)
    other-extensions:    PatternGuards
  else
    -- ... and more (see what SOP and SYB actually need)
    other-extensions:    PatternGuards, DeriveGeneric
--if impl(ghc >= 7.2)
--  other-extensions: Safe

  exposed-modules:
      Control.DeepSeq.Bounded
    , Control.DeepSeq.Bounded.Seqable
    , Control.DeepSeq.Bounded.NFDataN
    , Control.DeepSeq.Bounded.Pattern
    , Control.DeepSeq.Bounded.PatAlg
    , Control.DeepSeq.Bounded.NFDataP
  if ! flag(HASKELL98_FRAGMENT)
     exposed-modules:
         Control.DeepSeq.Bounded.Generics
       , Control.DeepSeq.Bounded.Generics.GNFDataN
     if flag(USE_SOP)
        exposed-modules:
            Control.DeepSeq.Bounded.Generics.GNFDataP
          , Control.DeepSeq.Bounded.Generics.GSeqable
          , Control.DeepSeq.Bounded.NFDataPDyn

  ghc-options: -optP-Wundef -fno-warn-overlapping-patterns

--ghc-options:         -Wall -fenable-rewrite-rules    -ddump-rules -ddump-simpl-stats -ddump-rule-firings
--ghc-options:         -Wall -fenable-rewrite-rules
  ghc-options:         -fenable-rewrite-rules   
--ghc-options:         -fenable-rewrite-rules -O2

  build-depends:
      base < 5
--    base       >= 4.3 && < 4.8
--    base >= 4.5 && < 4.8
    , array
--  , array      >= 0.3 && < 0.6
--  , sai-shape-syb
--- , ghc-syb-utils
    -- for Data.Tree
--  , containers
    , random

  if ! flag(HASKELL98_FRAGMENT)
     build-depends:
         syb

  -- deepseq not used for any legitimate reason, unless USE_WW_DEEPSEQ;
  -- but it's used in some debugging and testing code (although probably
  -- shouldn't be), so the dep stays for now:
  build-depends:
      deepseq
--    deepseq >= 1.2.0.1 && < 1.4

  if flag(USE_WW_DEEPSEQ)
     build-depends:
         deepseq
--       deepseq >= 1.2.0.1 && < 1.4
     if ! flag(HASKELL98_FRAGMENT)
        build-depends:
            deepseq-generics
     cpp-options: -DUSE_WW_DEEPSEQ=1
  else
     cpp-options: -DUSE_WW_DEEPSEQ=0

  if flag(WARN_PATTERN_MATCH_FAILURE)
     cpp-options: -DWARN_PATTERN_MATCH_FAILURE=1
  else
     cpp-options: -DWARN_PATTERN_MATCH_FAILURE=0

  if ! flag(HASKELL98_FRAGMENT)
      if flag(USE_SOP)
         build-depends:
             generics-sop
         cpp-options: -DUSE_SOP=1
      else
         cpp-options: -DUSE_SOP=0
  else
      cpp-options: -DUSE_SOP=0

  if flag(HASKELL98_FRAGMENT)
     cpp-options: -DHASKELL98_FRAGMENT=1
  else
     cpp-options: -DHASKELL98_FRAGMENT=0

  if flag(NFDATA_INSTANCE_PATTERN)
     cpp-options: -DNFDATA_INSTANCE_PATTERN=1
  else
     cpp-options: -DNFDATA_INSTANCE_PATTERN=0

  if flag(PARALLELISM_EXPERIMENT)
     build-depends:
         parallel

--if flag(SEQUENTIALISM_EXPERIMENT)
--   build-depends:
--       -- yes, really
--       parallel

  if flag(PARALLELISM_EXPERIMENT)
     cpp-options: -DPARALLELISM_EXPERIMENT=1
  else
     cpp-options: -DPARALLELISM_EXPERIMENT=0

--if flag(SEQUENTIALISM_EXPERIMENT)
--   cpp-options: -DSEQUENTIALISM_EXPERIMENT=1
--else
--   cpp-options: -DSEQUENTIALISM_EXPERIMENT=0

  if flag(JUST_ALIAS_GSEQABLE)
     cpp-options: -DJUST_ALIAS_GSEQABLE=1
  else
     cpp-options: -DJUST_ALIAS_GSEQABLE=0

}

test-suite deepseq-bounded-tests {

  if flag(HASKELL98_FRAGMENT)
    default-language: Haskell98
  else
    default-language: Haskell2010

  type:                exitcode-stdio-1.0
  hs-source-dirs:      test
  main-is:             Suite.hs
  other-modules:       Tests, Foo
  if flag(HASKELL98_FRAGMENT)
     other-modules:       Blah98
  else
     other-modules:       Blah, Bottom, FooG
  default-extensions:  CPP

  ghc-options: -optP-Wundef -fno-warn-overlapping-patterns

--ghc-options:         -Wall -fenable-rewrite-rules -O -ddump-rules -ddump-simpl-stats -ddump-rule-firings
--ghc-options:         -Wall -fenable-rewrite-rules -O
--ghc-options:         -fenable-rewrite-rules -O
  ghc-options:         -fenable-rewrite-rules -O2

  build-depends:
      base
    , deepseq-bounded
    , HUnit
    , random

    , template-haskell

  if ! flag(HASKELL98_FRAGMENT)
     build-depends:
         ghc-prim

  if ! flag(HASKELL98_FRAGMENT)
     build-depends:
         syb

  -- deepseq not used for any legitimate reason, unless USE_WW_DEEPSEQ;
  -- but it's used in some debugging and testing code (although probably
  -- shouldn't be), so the dep stays for now:
  build-depends:
      deepseq
--    deepseq >= 1.2.0.1 && < 1.4

  if flag(USE_WW_DEEPSEQ)
     build-depends:
         deepseq
--       deepseq >= 1.2.0.1 && < 1.4
     if ! flag(HASKELL98_FRAGMENT)
         build-depends:
             deepseq-generics
     cpp-options: -DUSE_WW_DEEPSEQ=1
  else
     cpp-options: -DUSE_WW_DEEPSEQ=0

  if ! flag(HASKELL98_FRAGMENT)
      if flag(USE_SOP)
         build-depends:
             generics-sop
         cpp-options: -DUSE_SOP=1
      else
         cpp-options: -DUSE_SOP=0
  else
      cpp-options: -DUSE_SOP=0

  if flag(HASKELL98_FRAGMENT)
     cpp-options: -DHASKELL98_FRAGMENT=1
  else
     cpp-options: -DHASKELL98_FRAGMENT=0

  if flag(PARALLELISM_EXPERIMENT)
     build-depends:
         parallel

--if flag(SEQUENTIALISM_EXPERIMENT)
--   build-depends:
--       -- yes, really
--       parallel

  if flag(PARALLELISM_EXPERIMENT)
     cpp-options: -DPARALLELISM_EXPERIMENT=1
  else
     cpp-options: -DPARALLELISM_EXPERIMENT=0

--if flag(SEQUENTIALISM_EXPERIMENT)
--   cpp-options: -DSEQUENTIALISM_EXPERIMENT=1
--else
--   cpp-options: -DSEQUENTIALISM_EXPERIMENT=0

  if flag(JUST_ALIAS_GSEQABLE)
     cpp-options: -DJUST_ALIAS_GSEQABLE=1
  else
     cpp-options: -DJUST_ALIAS_GSEQABLE=0

}