HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulehackage-security-0.6.4.0Haskell2010

Hackage.Security.Client.Verify

Contents
  1. Verification monad
  2. Specific resources
  3. Re-exports
Synopsis

Verification monad

newtypenewtype Verify a

Verification monad

The verification monad is similar to ResourceT in intent, in that we can register handlers to be run to release resources. Unlike ResourceT, however, we maintain _two_ handlers: a cleanup handler which is run whether or not verification succeeds, and a finalisation handler which is run only if verification succeeds.

  • Cleanup handlers are registered using acquire, and are guaranteed to run just before the computation terminates (after the finalisation handler).

  • The finalisation handlers are run only when verification succeeds, and can be registered with ifVerified. Finalisation can be used for instance to update the local cache (which should only happen if verification is successful).

Instances4Monad, Functor, Applicative, MonadIO
  • Monad VerifyDefined in hackage-security-0.6.4.0 · Hackage.Security.Client.Verify
  • Functor VerifyDefined in hackage-security-0.6.4.0 · Hackage.Security.Client.Verify
  • Applicative VerifyDefined in hackage-security-0.6.4.0 · Hackage.Security.Client.Verify
  • MonadIO VerifyDefined in hackage-security-0.6.4.0 · Hackage.Security.Client.Verify

Specific resources

Re-exports

methodliftIO :: IO a -> m a

Lift a computation from the IO monad. This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations (i.e. IO is the base monad for the stack).

Example
import Control.Monad.Trans.State -- from the "transformers" library

printState :: Show s => StateT s IO ()
printState = do
  state <- get
  liftIO $ print state

Had we omitted liftIO, we would have ended up with this error:

• Couldn't match type ‘IO’ with ‘StateT s IO’
 Expected type: StateT s IO ()
   Actual type: IO ()

The important part here is the mismatch between StateT s IO () and IO ().

Luckily, we know of a function that takes an IO a and returns an (m a): liftIO, enabling us to run the program and see the expected results:

> evalStateT printState "hello"
"hello"

> evalStateT printState 3
3