module Control.Teardown.Internal.Types where
import Protolude
import Data.Time.Clock (NominalDiffTime)
#if MIN_VERSION_base(4,9,0)
import Control.DeepSeq (NFData (..))
import GHC.Generics (Generic)
#endif
type Description = Text
data TeardownResult
= BranchResult
{
resultDescription :: !Description
, resultElapsedTime :: !NominalDiffTime
, resultDidFail :: !Bool
, resultListing :: ![TeardownResult]
}
| LeafResult
{
resultDescription :: !Description
, resultElapsedTime :: !NominalDiffTime
, resultError :: !(Maybe SomeException)
}
| EmptyResult
{
resultDescription :: !Description
}
deriving (Generic, Show)
instance NFData TeardownResult where
rnf result =
case result of
EmptyResult !_desc ->
()
LeafResult !_desc !_time !_err ->
()
BranchResult !_desc !_time !_didFail listing ->
rnf listing
newtype Teardown
= Teardown (IO TeardownResult)
deriving (Generic)
instance NFData Teardown where
rnf !_ = ()
class ITeardown teardown where
teardown :: teardown -> IO TeardownResult
class IResource resource where
newTeardown :: Text -> resource -> IO Teardown