teardown-0.3.0.0: Build composable components for your application with clear teardown semantics

Copyright(c) Roman Gonzalez 2017
LicenseMIT
Maintainerromanandreg@gmail.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Control.Teardown

Contents

Description

Provides functions that help on the creation of Application teardown sub-routines

Synopsis

Typeclasses for extending teardown functionality

class ITeardown teardown where #

A record that is or contains a Teardown sub-routine should instantiate this typeclass

Minimal complete definition

teardown

Methods

teardown :: teardown -> IO TeardownResult #

Executes teardown sub-routine returning a TeardownResult

Instances

class IResource resource where #

A resource or sub-routine that can be transformed into a Teardown operation

Minimal complete definition

newTeardown

Methods

newTeardown :: Text -> resource -> IO Teardown #

Cleanup main type and function

data Teardown #

Sub-routine that performs a resource cleanup operation

Instances

Generic Teardown # 

Associated Types

type Rep Teardown :: * -> * #

Methods

from :: Teardown -> Rep Teardown x #

to :: Rep Teardown x -> Teardown #

NFData Teardown # 

Methods

rnf :: Teardown -> () #

type Rep Teardown # 
type Rep Teardown = D1 * (MetaData "Teardown" "Control.Teardown.Internal.Types" "teardown-0.3.0.0-1x0ZUBVOkNcKDBdU0hScGy" True) (C1 * (MetaCons "Teardown" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (IO TeardownResult))))

data TeardownResult #

Result from a Teardown sub-routine

Constructors

BranchResult

Result is composed by multiple teardown sub-routines

Fields

LeafResult

Result represents a single teardown sub-routine

Fields

EmptyResult

Represents a stub cleanup operation (for lifting pure values)

Fields

teardown :: ITeardown teardown => teardown -> IO TeardownResult #

Executes teardown sub-routine returning a TeardownResult

Functions to create a Teardown record

emptyTeardown :: Description -> Teardown #

Creates a stub Teardown sub-routine, normally used when a contract expects a teardown return but there is no allocation being made

newTeardown :: IResource resource => Text -> resource -> IO Teardown #

Functions to deal with results from teardown call

didTeardownFail :: TeardownResult -> Bool #

Returns a boolean indicating if any of the cleanup sub-routine failed

failedToredownCount :: TeardownResult -> Int #

Returns number of sub-routines that threw an exception on execution of teardown

toredownCount :: TeardownResult -> Int #

Returns number of sub-routines executed at teardown

renderTeardownReport :: TeardownResult -> Doc #

Renders an ASCII Tree with the TeardownResult of a Teardown sub-routine execution