HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelibsodium-bindings-0.0.1.1Haskell2010

LibSodium.Bindings.Main

libsodium requires initialisation before use. We provide a binding to the initialisation function, as well as some high-level wrappers for applications to use without needing to call an FFI wrapper.

Note

If you are using cryptography-libsodium as a dependency for a library, you are probably not interested in this; it's designed for application authors who need capabilities provided by cryptography-libsodium.

  • 3 values

High-level wrappers

2 declarations
valuesecureMain
  1. :: IO a

    Action that will perform cryptographic operations

  2. -> IO a
#

Initialise all security-related functionality, then perform the given action. Abort with an error message if security-related functionality cannot be initialised. This will also indicate failure to the shell, as with die.

Use

main :: IO ()
main = secureMain doTheThingIActuallyWant
valuesecureMainWithError
  1. :: IO a

    Code to execute if there is an initialisation failure.

  2. -> IO a

    Action that will perform cryptographic operations after libsodium is initialised.

  3. -> IO a
#

Similar to secureMain, but allows responding to a failure of initialisation.

Use

main :: IO ()
main = secureMainWith reportErrorWithLogging doTheThingIActuallyWant

Low-level binding

1 declaration
valuesodiumInit
  1. :: IO CInt

    0 if successful, -1 on failure, 1 on repeat calls

#

Initialise libsodium for future use. This only needs to be called once, before any use of any other functionality, but multiple calls to this function are not harmful (just redundant).

See: sodium_init()