[commit: ghc] wip/gadtpm: Added a new flag (-guard-reasoning={simple, try, try-quiet, do}) (7e21605)

git at git.haskell.org git at git.haskell.org
Sat Dec 19 16:02:27 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/gadtpm
Link       : http://ghc.haskell.org/trac/ghc/changeset/7e216050ce0366a1d2c2a971db457a5d49f60e8a/ghc

>---------------------------------------------------------------

commit 7e216050ce0366a1d2c2a971db457a5d49f60e8a
Author: George Karachalias <george.karachalias at gmail.com>
Date:   Sat Dec 19 17:02:36 2015 +0100

    Added a new flag (-guard-reasoning={simple,try,try-quiet,do})
    
    Options:
    ~~~~~~~~
      simple    : Like old times (see only `otherwise`)
      try       : Default: If guards>20, bail. Issue waring below.
      try-quiet : If too many guards, skip check, issue no warning
      do        : Run the check fully (but may use up all resources)
    
    Warning:
    ~~~~~~~~
    Pattern match checking omitted for an equation for `opt_trans_rule'
    because it may be non-performant (too many guards)
    Use: -guard-reasoning=simple
           for a more efficient (but less expressive) pattern guard checking
         -guard-reasoning=try-quiet
           to suppress this warning for inefficiently checked matches
         -guard-reasoning=do
           to fully check the match (may run out of memory)
    
    If the guards are too many, the suggested strategy is the following:
    
    1) First try -guard-reasoning=simple. The simple version of the checker
       may still be able to emit the correct warnings.
    
    2) If you still get some warnings but you are confident that there
       shouldn't be any, try -guard-reasoning=do.
    
    3) If the compilation takes too long but you are sure that your match
       is exhaustive and nothing is redundant, you can either:
       * Disable the check for matches with many guards with
         -guard-reasoning=try-quiet (useful if you compile with -Werror) or
       * Do nothing, just keep the warning as a reminder.
    
    With the current state of GHC, the above warning is emitted only for:
    
    libraries/base/Foreign/C/Error.hs:472:5:      function `errType'
    compiler/nativeGen/Dwarf/Constants.hs:170:18: (case expression)
    compiler/ghci/RtClosureInspect.hs:497:4:      function `rep'
    (And would have been for compiler/types/OptCoercion.hs, for which the
    check is currently disabled)
    
    Note that for Error.hs, Constants.hs and RtClosureInspect.hs we can
    safely enable "-guard-reasoning=do". For OptCoercion.hs the full
    check takes forever to complete (and uses up all the memory) but with
    "-guard-reasoning=simple" we can both have it checked and in reasonable
    time.
    
    ("-guard-reasoning=do" not enabled in Error.hs because it is in a
    submodule. Left it to the library maintainer)


>---------------------------------------------------------------

7e216050ce0366a1d2c2a971db457a5d49f60e8a
 compiler/deSugar/Check.hs             | 84 ++++++++++++++++++++++++++++++-----
 compiler/deSugar/Match.hs             | 37 ++++++++++++---
 compiler/ghci/RtClosureInspect.hs     |  3 ++
 compiler/main/DynFlags.hs             | 20 +++++++++
 compiler/nativeGen/Dwarf/Constants.hs |  4 ++
 compiler/types/OptCoercion.hs         |  5 ++-
 6 files changed, 136 insertions(+), 17 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 7e216050ce0366a1d2c2a971db457a5d49f60e8a


More information about the ghc-commits mailing list