[commit: ghc] master: Change some "else return ()"s to use when/unless (05a0a64)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/05a0a6474338af410a90296cff9dfea50773f4ca

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

commit 05a0a6474338af410a90296cff9dfea50773f4ca
Author: Ian Lynagh <[email protected]>
Date:   Thu Sep 20 00:43:34 2012 +0100

    Change some "else return ()"s to use when/unless

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

 compiler/codeGen/StgCmmBind.hs   |    3 +--
 compiler/codeGen/StgCmmLayout.hs |    3 ++-
 compiler/main/DynFlags.hs        |    5 ++---
 compiler/typecheck/TcRnMonad.lhs |   12 ++++++------
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs
index 02d3d02..89d27dd 100644
--- a/compiler/codeGen/StgCmmBind.hs
+++ b/compiler/codeGen/StgCmmBind.hs
@@ -468,8 +468,7 @@ closureCodeBody top_lvl bndr cl_info cc args arity body fv_details
                 { fv_bindings <- mapM bind_fv fv_details
                 -- Load free vars out of closure *after*
                 -- heap check, to reduce live vars over check
-                ; if node_points then load_fvs node lf_info fv_bindings
-                                 else return ()
+                ; when node_points $ load_fvs node lf_info fv_bindings
                 ; void $ cgExpr body
                 }}
   }
diff --git a/compiler/codeGen/StgCmmLayout.hs b/compiler/codeGen/StgCmmLayout.hs
index 69a0d1a..fa80edc 100644
--- a/compiler/codeGen/StgCmmLayout.hs
+++ b/compiler/codeGen/StgCmmLayout.hs
@@ -61,6 +61,7 @@ import Util
 import Data.List
 import Outputable
 import FastString
+import Control.Monad
 
 ------------------------------------------------------------------------
 --		Call and return sequences
@@ -86,7 +87,7 @@ emitReturn results
              do { adjustHpBackwards
                 ; emit (mkReturnSimple dflags results updfr_off) }
            AssignTo regs adjust ->
-             do { if adjust then adjustHpBackwards else return ()
+             do { when adjust adjustHpBackwards
                 ; emitMultiAssign  regs results }
        ; return AssignedDirectly
        }
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 70ade2a..080539a 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -2424,9 +2424,8 @@ xFlags = [
   ( "MultiWayIf",                       Opt_MultiWayIf, nop ),
   ( "MonoLocalBinds",                   Opt_MonoLocalBinds, nop ),
   ( "RelaxedPolyRec",                   Opt_RelaxedPolyRec,
-    \ turn_on -> if not turn_on
-                 then deprecate "You can't turn off RelaxedPolyRec any more"
-                 else return () ),
+    \ turn_on -> unless turn_on
+               $ deprecate "You can't turn off RelaxedPolyRec any more" ),
   ( "ExtendedDefaultRules",             Opt_ExtendedDefaultRules, nop ),
   ( "ImplicitParams",                   Opt_ImplicitParams, nop ),
   ( "ScopedTypeVariables",              Opt_ScopedTypeVariables, nop ),
diff --git a/compiler/typecheck/TcRnMonad.lhs b/compiler/typecheck/TcRnMonad.lhs
index 8b84d55..3cfc704 100644
--- a/compiler/typecheck/TcRnMonad.lhs
+++ b/compiler/typecheck/TcRnMonad.lhs
@@ -285,16 +285,16 @@ unsetWOptM flag = updEnv (\ env@(Env { env_top = top }) ->
 
 -- | Do it flag is true
 ifDOptM :: DynFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
-ifDOptM flag thing_inside = do { b <- doptM flag ;
-                                if b then thing_inside else return () }
+ifDOptM flag thing_inside = do b <- doptM flag
+                               when b thing_inside
 
 ifWOptM :: WarningFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
-ifWOptM flag thing_inside = do { b <- woptM flag ;
-                                if b then thing_inside else return () }
+ifWOptM flag thing_inside = do b <- woptM flag
+                               when b thing_inside
 
 ifXOptM :: ExtensionFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
-ifXOptM flag thing_inside = do { b <- xoptM flag ;
-                                if b then thing_inside else return () }
+ifXOptM flag thing_inside = do b <- xoptM flag
+                               when b thing_inside
 
 getGhcMode :: TcRnIf gbl lcl GhcMode
 getGhcMode = do { env <- getTopEnv; return (ghcMode (hsc_dflags env)) }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.