polysemy-0.3.0.0: Higher-order, low-boilerplate, zero-cost free monads.

Safe HaskellNone
LanguageHaskell2010

Polysemy.Resource

Contents

Synopsis

Effect

data Resource m a where Source #

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 

Fields

  • :: m a

    Action to allocate a resource.

  • -> (a -> m ())

    Action to cleanup the resource. This is guaranteed to be called.

  • -> (a -> m b)

    Action which uses the resource.

  • -> Resource m b
     
Instances
type DefiningModule Resource Source # 
Instance details

Defined in Polysemy.Resource

type DefiningModule Resource = "Polysemy.Resource"

Actions

bracket :: forall r a a. Member Resource r => Sem r a -> (a -> Sem r ()) -> (a -> Sem r a) -> Sem r a Source #

Interpretations

runResource Source #

Arguments

:: Member (Lift IO) r 
=> (forall x. Sem r x -> IO x)

Strategy for lowering a Sem action down to IO. This is likely some combination of runM and other interpreters composed via .@.

-> Sem (Resource ': r) a 
-> Sem r a 

Run a Resource effect via in terms of bracket.