polysemy-0.1.1.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 semantic. 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 a b. forall r. Member Resource r => Semantic r a -> (a -> Semantic r ()) -> (a -> Semantic r b) -> Semantic r b Source #

Interpretations

runResource Source #

Arguments

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

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

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

Run a Resource effect via in terms of bracket.