Skip to content
This repository
Browse code

refactored error handling in .@.

  • Loading branch information...
commit 591bb077043592cc4d1bff0127f4b6ee61cf286e 1 parent 321927f
authored May 12, 2012

Showing 2 changed files with 3 additions and 3 deletions. Show diff stats Hide diff stats

  1. 1  .gitignore
  2. 5  src/Main.hs
1  .gitignore
... ...
@@ -1,3 +1,4 @@
1 1
 *.hi
2 2
 *.o
  3
+*.swp
3 4
 dist/
5  src/Main.hs
@@ -115,12 +115,11 @@ a @>-<@ b =
115 115
 (<@) s = do (c,_) <- accept s; configure c; print . (:.:) Accept =<< (c <@>); return c
116 116
 
117 117
 (.@.) :: Host -> Port -> IO Socket
118  
-h .@. p = do -- (X.throwIO (e Nothing) ???) . map c =<< getAddrInfo hint host port
119  
-  as <- getAddrInfo hint host port
120  
-  X.throwIO (Silence $ map addrAddress as) ??? map c as
  118
+h .@. p = getAddrInfo hint host port >>= \as -> e as ??? map c as
121 119
   where hint = Just $! defaultHints { addrSocketType = Stream }
122 120
         host = Just $! B.unpack h
123 121
         port = Just $! show     p
  122
+        e as = X.throwIO . Silence $ map addrAddress as
124 123
         c a  = do s <-      socket (addrFamily  a) Stream 0x6 =>> configure
125 124
                   r <- s `connect`  addrAddress a // timeout (secs 3)
126 125
                   case r of

0 notes on commit 591bb07

Please sign in to comment.
Something went wrong with that request. Please try again.