Permalink
Browse files

refactored error handling in .@.

  • Loading branch information...
Cetin Sert Cetin Sert
Cetin Sert authored and Cetin Sert committed May 11, 2012
1 parent 321927f commit 591bb077043592cc4d1bff0127f4b6ee61cf286e
Showing with 3 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +2 −3 src/Main.hs
View
@@ -1,3 +1,4 @@
*.hi
*.o
*.swp
dist/
View
@@ -115,12 +115,11 @@ a @>-<@ b =
(<@) s = do (c,_) <- accept s; configure c; print . (:.:) Accept =<< (c <@>); return c
(.@.) :: Host -> Port -> IO Socket
h .@. p = do -- (X.throwIO (e Nothing) ???) . map c =<< getAddrInfo hint host port
as <- getAddrInfo hint host port
X.throwIO (Silence $ map addrAddress as) ??? map c as
h .@. p = getAddrInfo hint host port >>= \as -> e as ??? map c as
where hint = Just $! defaultHints { addrSocketType = Stream }
host = Just $! B.unpack h
port = Just $! show p
e as = X.throwIO . Silence $ map addrAddress as
c a = do s <- socket (addrFamily a) Stream 0x6 =>> configure
r <- s `connect` addrAddress a // timeout (secs 3)
case r of

0 comments on commit 591bb07

Please sign in to comment.