data-effects-0.1.2.0: A basic framework for effect systems based on effects represented by GADTs.
Copyright(c) 2019-2023 The Polysemy Lounge
(c) 2023 Yamada Ryo
LicenseMPL-2.0 (see the file LICENSE)
Maintainerymdfield@outlook.jp
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Effect.Resource

Description

An effect capable of providing bracket semantics.

Synopsis

Documentation

data Resource f a where Source #

An effect capable of providing bracket semantics.

Constructors

Bracket :: f a -> (a -> f ()) -> (a -> f b) -> Resource f b

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

BracketOnExcept :: f a -> (a -> f ()) -> (a -> f b) -> Resource f b

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

Instances

Instances details
() => HFunctor Resource Source # 
Instance details

Defined in Data.Effect.Resource

Methods

hfmap :: forall (f :: Type -> Type) (g :: Type -> Type). (f :-> g) -> Resource f :-> Resource g #

bracketOnExcept'' :: forall key (a :: Type) (b :: Type) f. SendSigBy key Resource f => f a -> (a -> f ()) -> (a -> f b) -> f b Source #

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

bracketOnExcept' :: forall tag (a :: Type) (b :: Type) f. SendSig (TagH Resource tag) f => f a -> (a -> f ()) -> (a -> f b) -> f b Source #

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

bracketOnExcept :: forall (a :: Type) (b :: Type) f. SendSig Resource f => f a -> (a -> f ()) -> (a -> f b) -> f b Source #

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

bracket'' :: forall key (a :: Type) (b :: Type) f. SendSigBy key Resource f => f a -> (a -> f ()) -> (a -> f b) -> f b Source #

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

bracket' :: forall tag (a :: Type) (b :: Type) f. SendSig (TagH Resource tag) f => f a -> (a -> f ()) -> (a -> f b) -> f b Source #

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

bracket :: forall (a :: Type) (b :: Type) f. SendSig Resource f => f a -> (a -> f ()) -> (a -> f b) -> f b Source #

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

bracket_ :: (Resource <<: f, Functor f) => f a -> f b -> f c -> f c Source #

bracketOnExcept_ :: (Resource <<: f, Functor f) => f a -> f b -> f c -> f c Source #

finally :: (Resource <<: f, Applicative f) => f a -> f () -> f a Source #

finally_ :: (Resource <<: f, Applicative f) => f a -> f b -> f a Source #

onException :: (Resource <<: f, Applicative f) => f a -> f () -> f a Source #

onException_ :: (Resource <<: f, Applicative f) => f a -> f b -> f a Source #