diff options
author | Kazu Yamamoto <kazu@iij.ad.jp> | 2012-12-28 12:54:03 +0900 |
---|---|---|
committer | Johan Tibell <johan.tibell@gmail.com> | 2013-02-11 21:38:07 -0800 |
commit | 63981cb6bbc575f6625d41ffb71bcbac31b3f6c5 (patch) | |
tree | 3ebe0d4376274a1bc64fa4f95e8e8a776fddec22 /libraries | |
parent | a691b2d846f34dfc580d5de36d644c190833ad08 (diff) | |
download | haskell-63981cb6bbc575f6625d41ffb71bcbac31b3f6c5.tar.gz |
refactoring with guard.
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/GHC/Event/KQueue.hsc | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/libraries/base/GHC/Event/KQueue.hsc b/libraries/base/GHC/Event/KQueue.hsc index 2d37546842..abf7eca3e0 100644 --- a/libraries/base/GHC/Event/KQueue.hsc +++ b/libraries/base/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 |