HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Modulelibsodium-bindings-0.0.3.0Haskell2010

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.

Usage:
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.

Usage:
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()