[commit: base] : refactoring with guard. (3dddd54)

Johan Tibell johan.tibell at gmail.com
Tue Feb 12 07:51:28 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : 

http://hackage.haskell.org/trac/ghc/changeset/3dddd548bbcf39d873058bae6a9e27d5dea308d6

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

commit 3dddd548bbcf39d873058bae6a9e27d5dea308d6
Author: Kazu Yamamoto <kazu at iij.ad.jp>
Date:   Fri Dec 28 12:54:03 2012 +0900

    refactoring with guard.

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

 GHC/Event/KQueue.hsc |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/GHC/Event/KQueue.hsc b/GHC/Event/KQueue.hsc
index 2d37546..abf7eca 100644
--- a/GHC/Event/KQueue.hsc
+++ b/GHC/Event/KQueue.hsc
@@ -303,11 +303,9 @@ withEvent :: Event -> (Ptr Event -> IO a) -> IO a
 withEvent ev f = alloca $ \ptr -> poke ptr ev >> f ptr
 
 withTimeSpec :: TimeSpec -> (Ptr TimeSpec -> IO a) -> IO a
-withTimeSpec ts f =
-    if tv_sec ts < 0 then
-        f nullPtr
-      else
-        alloca $ \ptr -> poke ptr ts >> f ptr
+withTimeSpec ts f
+  | tv_sec ts < 0 = f nullPtr
+  | otherwise     = alloca $ \ptr -> poke ptr ts >> f ptr
 
 fromTimeout :: Timeout -> TimeSpec
 fromTimeout Forever     = TimeSpec (-1) (-1)
@@ -321,9 +319,9 @@ fromTimeout (Timeout s) = TimeSpec (toEnum sec) (toEnum nanosec)
 
 toEvent :: Filter -> E.Event
 toEvent (Filter f)
-    | f == (#const EVFILT_READ) = E.evtRead
-    | f == (#const EVFILT_WRITE) = E.evtWrite
-    | otherwise = error $ "toEvent: unknown filter " ++ show f
+  | f == (#const EVFILT_READ) = E.evtRead
+  | f == (#const EVFILT_WRITE) = E.evtWrite
+  | otherwise = error $ "toEvent: unknown filter " ++ show f
 
 foreign import ccall unsafe "kqueue"
     c_kqueue :: IO CInt





More information about the ghc-commits mailing list