Skip to content

Commit

Permalink
removing async
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Nov 16, 2024
1 parent ad0adfc commit 2de2f05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 9 additions & 4 deletions tls/Network/TLS/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module Network.TLS.Util (
import qualified Data.ByteString as B
import Network.TLS.Imports

import Control.Concurrent.Async
import Control.Concurrent.MVar
import Control.Exception (SomeException)
import Control.Exception (SomeAsyncException (..))
import qualified Control.Exception as E

sub :: ByteString -> Int -> Int -> Maybe ByteString
sub b offset len
Expand Down Expand Up @@ -69,8 +69,13 @@ False &&! False = False
fmapEither :: (a -> b) -> Either l a -> Either l b
fmapEither f = fmap f

catchException :: IO a -> (SomeException -> IO a) -> IO a
catchException action handler = withAsync action waitCatch >>= either handler return
catchException :: IO a -> (E.SomeException -> IO a) -> IO a
catchException f handler = E.catchJust filterExn f handler
where
filterExn :: E.SomeException -> Maybe E.SomeException
filterExn e = case E.fromException (E.toException e) of
Just (SomeAsyncException _) -> Nothing
Nothing -> Just e

forEitherM :: Monad m => [a] -> (a -> m (Either l b)) -> m (Either l [b])
forEitherM [] _ = return (pure [])
Expand Down
1 change: 0 additions & 1 deletion tls/tls.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ library
base >=4.9 && <5,
asn1-encoding >= 0.9 && < 0.10,
asn1-types >= 0.3 && < 0.4,
async >= 2.2 && < 2.3,
base16-bytestring,
bytestring >= 0.10 && < 0.13,
cereal >= 0.5.3 && < 0.6,
Expand Down

0 comments on commit 2de2f05

Please sign in to comment.