zeugma-0.11.0.0: lib/Zeugma/TestError.hs
{-# language NoImplicitPrelude #-}
{-# options_haddock prune #-}
-- | Combinators related to 'TestError'.
module Zeugma.TestError where
import Incipit
import Polysemy.Test (TestError (TestError))
-- | Interpret 'Stop' by throwing a 'TestError', with the call site's stack.
stopTest ::
∀ err r .
Show err =>
HasCallStack =>
Member (Error TestError) r =>
InterpreterFor (Stop err) r
stopTest ma =
withFrozenCallStack (stopToErrorWith (TestError . show) ma)
-- | Interpret an effect into 'Resumable' by throwing a 'TestError' for 'Stop's, with the call site's stack.
resumeTest ::
∀ err eff r .
Show err =>
HasCallStack =>
Members [eff !! err, Error TestError] r =>
InterpreterFor eff r
resumeTest ma =
withFrozenCallStack (resumeHoistError @err (TestError . show) ma)
-- | Interpret 'Error' converting the error to 'TestError', with the call site's stack.
errorTest ::
∀ err r .
Show err =>
HasCallStack =>
Member (Error TestError) r =>
InterpreterFor (Error err) r
errorTest ma =
withFrozenCallStack (mapError (TestError . show) ma)