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

git at git.haskell.org git at git.haskell.org
Mon Dec 21 00:11:40 UTC 2015


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

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

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

commit f86de30aedc0b042e170a0359dee40d58cfb9a34
Author: George Karachalias <george.karachalias at gmail.com>
Date:   Sun Dec 20 20:36:27 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)


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

f86de30aedc0b042e170a0359dee40d58cfb9a34
 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 f86de30aedc0b042e170a0359dee40d58cfb9a34


More information about the ghc-commits mailing list