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

Modulepolysemy-1.9.2.0Haskell2010

Polysemy.Error

  • 1 type
  • 15 values
  • Packagepolysemy-1.9.2.0
  • Exports16
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceError.hs

Effect

1 declaration
datadata Error e (m :: k -> Type) (a :: k) where
#

This effect abstracts the throwing and catching of errors, leaving it up to the interpreter whether to use exceptions or monad transformers like ExceptT to perform the short-circuiting mechanism.

Constructors

  • Throw :: e -> Error e m a

    Short-circuit the current program using the given error value.

  • Catch :: m a -> (e -> m a) -> Error e m a

    Recover from an error that might have been thrown in the higher-order action given by the first argument by passing the error to the handler given by the second argument.

Actions

12 declarations
valuethrow :: Member (Error e) r => e -> Sem r a
#

Short-circuit the current program using the given error value.

valuecatch :: Member (Error e) r => Sem r a -> (e -> Sem r a) -> Sem r a
#

Recover from an error that might have been thrown in the higher-order action given by the first argument by passing the error to the handler given by the second argument.

valuecatchJust
  1. :: Member (Error e) r
  2. => (e -> Maybe b)

    Predicate to select exceptions

  3. -> Sem r a

    Computation to run

  4. -> (b -> Sem r a)

    Handler

  5. -> Sem r a
#

The function catchJust is like catch, but it takes an extra argument which is an exception predicate, a function which selects which type of exceptions we're interested in.

Interpretations

3 declarations
valuemapError
  1. :: Member (Error e2) r
  2. => e1 -> e2
  3. -> Sem (Error e1 ': r) a
  4. -> Sem r a
#

Transform one Error into another. This function can be used to aggregate multiple errors into a single type.