Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype SetupFunc b a = SetupFunc {
- unSetupFunc :: forall r. (a -> IO r) -> b -> IO r
- makeSimpleSetupFunc :: (forall r. (a -> IO r) -> IO r) -> SetupFunc () a
- useSimpleSetupFunc :: SetupFunc () a -> forall r. (a -> IO r) -> IO r
- wrapSetupFunc :: (b -> SetupFunc () a) -> SetupFunc b a
- unwrapSetupFunc :: SetupFunc b a -> b -> SetupFunc () a
- composeSetupFunc :: SetupFunc b a -> SetupFunc c b -> SetupFunc c a
- connectSetupFunc :: SetupFunc c b -> SetupFunc b a -> SetupFunc c a
- setupAround :: SetupFunc () c -> TestDefM a c e -> TestDefM a () e
- setupAroundWith :: SetupFunc d c -> TestDefM a c e -> TestDefM a d e
- setupAroundWith' :: HContains l a => (a -> SetupFunc d c) -> TestDefM l c e -> TestDefM l d e
Documentation
newtype SetupFunc b a Source #
A function that can provide an a
given a b
.
You can think of this as a potentially-resource-aware version of 'b -> IO a'.
SetupFunc | |
|
makeSimpleSetupFunc :: (forall r. (a -> IO r) -> IO r) -> SetupFunc () a Source #
Turn a simple provider function into a SetupFunc
.
This works together nicely with most supplier functions. Some examples:
useSimpleSetupFunc :: SetupFunc () a -> forall r. (a -> IO r) -> IO r Source #
Use a 'SetupFunc ()' as a simple provider function.
This is the opposite of the makeSimpleSetupFunc
function
wrapSetupFunc :: (b -> SetupFunc () a) -> SetupFunc b a Source #
Wrap a function that produces a SetupFunc
to into a SetupFunc
.
This is useful to combine a given 'SetupFunc b' with other 'SetupFunc ()'s as follows:
mySetupFunc :: SetupFunc B A mySetupFunc = wrapSetupFunc $ \b -> do r <- setupSomething c <- setupSomethingElse b r pure $ somehowCombine c r setupSomething :: SetupFunc () R setupSomething :: B -> R -> SetupFunc () C somehowCombine :: C -> R -> A
unwrapSetupFunc :: SetupFunc b a -> b -> SetupFunc () a Source #
Unwrap a SetupFunc
into a function that produces a SetupFunc
This is the opposite of wrapSetupFunc
.
connectSetupFunc :: SetupFunc c b -> SetupFunc b a -> SetupFunc c a Source #
Connect two setup functions.
This is basically 'flip (.)' but for SetupFunc
s.
It's exactly 'flip composeSetupFunc'.
setupAroundWith :: SetupFunc d c -> TestDefM a c e -> TestDefM a d e Source #
Use aroundWith
with a SetupFunc
setupAroundWith' :: HContains l a => (a -> SetupFunc d c) -> TestDefM l c e -> TestDefM l d e Source #
Use aroundWith'
with a SetupFunc