Copyright | (c) 2019-2023 The Polysemy Lounge (c) 2023 Sayo Koyoneda |
---|---|
License | MPL-2.0 (see the file LICENSE) |
Maintainer | ymdfield@outlook.jp |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | GHC2021 |
An effect capable of providing bracket semantics.
Synopsis
- data Resource (f :: Type -> Type) a where
- bracket :: forall a b f. SendHOE Resource f => f a -> (a -> f ()) -> (a -> f b) -> f b
- bracket' :: forall {k} (tag :: k) a b f. SendHOE (TagH Resource tag) f => f a -> (a -> f ()) -> (a -> f b) -> f b
- bracket'' :: forall {k} (key :: k) a b f. SendHOEBy key Resource f => f a -> (a -> f ()) -> (a -> f b) -> f b
- bracketOnExcept :: forall a b f. SendHOE Resource f => f a -> (a -> f ()) -> (a -> f b) -> f b
- bracketOnExcept' :: forall {k} (tag :: k) a b f. SendHOE (TagH Resource tag) f => f a -> (a -> f ()) -> (a -> f b) -> f b
- bracketOnExcept'' :: forall {k} (key :: k) a b f. SendHOEBy key Resource f => f a -> (a -> f ()) -> (a -> f b) -> f b
- bracket_ :: (Resource <<: f, Functor f) => f a -> f b -> f c -> f c
- bracketOnExcept_ :: (Resource <<: f, Functor f) => f a -> f b -> f c -> f c
- finally :: (Resource <<: f, Applicative f) => f a -> f () -> f a
- finally_ :: (Resource <<: f, Applicative f) => f a -> f b -> f a
- onException :: (Resource <<: f, Applicative f) => f a -> f () -> f a
- onException_ :: (Resource <<: f, Applicative f) => f a -> f b -> f a
Documentation
data Resource (f :: Type -> Type) a where Source #
An effect capable of providing bracket semantics.
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. |
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.
onException :: (Resource <<: f, Applicative f) => f a -> f () -> f a Source #
onException_ :: (Resource <<: f, Applicative f) => f a -> f b -> f a Source #