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.Resource

  • 1 type
  • 7 values
  • Packagepolysemy-1.9.2.0
  • Exports8
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceResource.hs

Effect

1 declaration
datadata Resource (m :: Type -> Type) a where
#

An effect capable of providing bracket semantics. Interpreters for this will successfully run the deallocation action even in the presence of other short-circuiting effects.

Constructors

  • Bracket :: m a1 -> (a1 -> m c) -> (a1 -> m a) -> Resource m a

    Allocate a resource, use it, and clean it up afterwards.

  • BracketOnError :: m a1 -> (a1 -> m c) -> (a1 -> m a) -> Resource m a

    Allocate a resource, use it, and clean it up afterwards if an error occurred.

Actions

5 declarations
valuebracket_
  1. :: Member Resource r
  2. => Sem r a

    computation to run first

  3. -> Sem r b

    computation to run last (even if an exception was raised)

  4. -> Sem r c

    computation to run in-between

  5. -> Sem r c
#

A variant of bracket where the return value from the first computation is not required.

cf. bracket and bracket_

valuefinally
  1. :: Member Resource r
  2. => Sem r a

    computation to run first

  3. -> Sem r b

    computation to run afterward (even if an exception was raised)

  4. -> Sem r a
#

Like bracket, but for the simple case of one computation to run afterward.

Interpretations

2 declarations