Last active
August 29, 2015 14:09
-
-
Save sshine/396df7674bf6270dc7f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo :: IO (Maybe Socket) -> IO () -> IO (Maybe Socket) | |
foo sock action = do | |
actionHandler <- tryIOError action | |
return $ either (\err -> Nothing) (\sock' -> sock <|> Just sock') actionHandler | |
performSocketAction2 :: Socket -> IO () -> IO (Maybe Socket) | |
performSocketAction2 sock action = foo (Just sock) action | |
makeSocket :: IO (Socket) -> IO (Maybe Socket) | |
makeSocket action = foo Nothing action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment