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

Data.Effect.Resource

Description

An effect capable of providing bracket semantics.

Synopsis

Documentation

data Resource (f :: Type -> Type) a where Source #

An effect capable of providing bracket semantics.

Constructors

Bracket :: forall (f :: Type -> Type) a1 a. f a1 -> (a1 -> f ()) -> (a1 -> f a) -> Resource f a

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

BracketOnExcept :: forall (f :: Type -> Type) a1 a. f a1 -> (a1 -> f ()) -> (a1 -> f a) -> Resource f a

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 #

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

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

bracket' :: forall {k} (tag :: k) a b f. SendHOE (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 {k} (key :: k) a b f. SendHOEBy key Resource f => f a -> (a -> f ()) -> (a -> f b) -> f b Source #

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

bracketOnExcept :: forall a b f. SendHOE 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 {k} (tag :: k) a b f. SendHOE (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 {k} (key :: k) a b f. SendHOEBy 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.

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 #