Skip to content

Commit

Permalink
refactored error handling in .@.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cetin Sert authored and Cetin Sert committed May 11, 2012
1 parent 321927f commit 591bb07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
*.hi
*.o
*.swp
dist/
5 changes: 2 additions & 3 deletions src/Main.hs
Expand Up @@ -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
Expand Down

0 comments on commit 591bb07

Please sign in to comment.