module Cardano.Crypto.Libsodium.Init (
sodiumInit,
) where
import Control.Monad (unless)
import Cardano.Crypto.Libsodium.C
sodiumInit :: IO ()
sodiumInit :: IO ()
sodiumInit = do
Int
res <- IO Int
c_sodium_init
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int
res Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 Bool -> Bool -> Bool
|| Int
res Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"sodium_init failed"