diff options
author | Benjamin Barenblat <bbaren@google.com> | 2018-08-31 16:50:41 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2018-08-31 16:50:41 -0400 |
commit | 80f2fb2e3be2c4074fbfb0adbc47746d2d88813b (patch) | |
tree | ca49c396dea7463c7c5088a8134f98e2bdfd6756 /src/BTLS/Result.hs | |
parent | d1a85eb87934d348c9789aec59c751fa615ec363 (diff) |
Begin switching to `fun` in c2hs
Replace most invocations of `call` with `fun`. There’s a lot of explicit
`id`-marshalling going on; future commits will remove it.
Diffstat (limited to 'src/BTLS/Result.hs')
-rw-r--r-- | src/BTLS/Result.hs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/BTLS/Result.hs b/src/BTLS/Result.hs index b9ad4a7..6cac7b9 100644 --- a/src/BTLS/Result.hs +++ b/src/BTLS/Result.hs @@ -15,13 +15,11 @@ module BTLS.Result where import Control.Exception (assert) -import Foreign (throwIf_) +import Control.Monad (when) import Foreign.C.Types -alwaysSucceeds :: IO CInt -> IO () -alwaysSucceeds f = do - r <- f - assert (r == 1) (return ()) +alwaysSucceeds :: CInt -> IO () +alwaysSucceeds r = assert (r == 1) (return ()) -requireSuccess :: IO CInt -> IO () -requireSuccess f = throwIf_ (/= 1) (const "BoringSSL failure") f +requireSuccess :: CInt -> IO () +requireSuccess r = when (r /= 1) $ ioError (userError "BoringSSL failure") |