{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE CPP #-}

-- | The core Spec/SpecCommand types, used to define the test free monad.

module Test.Sandwich.Types.Spec where

import Control.Applicative
import Control.Exception.Safe
import Control.Monad.Base
import Control.Monad.Free
import Control.Monad.Free.TH
import Control.Monad.IO.Unlift
import Control.Monad.Logger
import Control.Monad.Reader
import Control.Monad.Trans.Control
import Data.Functor.Classes
import Data.Kind (Type)
import Data.Maybe
import Data.String.Interpolate
import Data.Time
import GHC.Stack
import GHC.TypeLits
import Graphics.Vty.Image (Image)
import Safe

#if !MIN_VERSION_base(4,13,0)
import Control.Monad.Fail
#endif


-- * ExampleM monad

newtype ExampleT context m a = ExampleT { forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT :: ReaderT context (LoggingT m) a }
  deriving ((forall a b.
 (a -> b) -> ExampleT context m a -> ExampleT context m b)
-> (forall a b. a -> ExampleT context m b -> ExampleT context m a)
-> Functor (ExampleT context m)
forall a b. a -> ExampleT context m b -> ExampleT context m a
forall a b.
(a -> b) -> ExampleT context m a -> ExampleT context m b
forall context (m :: * -> *) a b.
Functor m =>
a -> ExampleT context m b -> ExampleT context m a
forall context (m :: * -> *) a b.
Functor m =>
(a -> b) -> ExampleT context m a -> ExampleT context m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall context (m :: * -> *) a b.
Functor m =>
(a -> b) -> ExampleT context m a -> ExampleT context m b
fmap :: forall a b.
(a -> b) -> ExampleT context m a -> ExampleT context m b
$c<$ :: forall context (m :: * -> *) a b.
Functor m =>
a -> ExampleT context m b -> ExampleT context m a
<$ :: forall a b. a -> ExampleT context m b -> ExampleT context m a
Functor, Functor (ExampleT context m)
Functor (ExampleT context m) =>
(forall a. a -> ExampleT context m a)
-> (forall a b.
    ExampleT context m (a -> b)
    -> ExampleT context m a -> ExampleT context m b)
-> (forall a b c.
    (a -> b -> c)
    -> ExampleT context m a
    -> ExampleT context m b
    -> ExampleT context m c)
-> (forall a b.
    ExampleT context m a
    -> ExampleT context m b -> ExampleT context m b)
-> (forall a b.
    ExampleT context m a
    -> ExampleT context m b -> ExampleT context m a)
-> Applicative (ExampleT context m)
forall a. a -> ExampleT context m a
forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m a
forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
forall a b.
ExampleT context m (a -> b)
-> ExampleT context m a -> ExampleT context m b
forall a b c.
(a -> b -> c)
-> ExampleT context m a
-> ExampleT context m b
-> ExampleT context m c
forall context (m :: * -> *).
Applicative m =>
Functor (ExampleT context m)
forall context (m :: * -> *) a.
Applicative m =>
a -> ExampleT context m a
forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m a
forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m (a -> b)
-> ExampleT context m a -> ExampleT context m b
forall context (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ExampleT context m a
-> ExampleT context m b
-> ExampleT context m c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
$cpure :: forall context (m :: * -> *) a.
Applicative m =>
a -> ExampleT context m a
pure :: forall a. a -> ExampleT context m a
$c<*> :: forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m (a -> b)
-> ExampleT context m a -> ExampleT context m b
<*> :: forall a b.
ExampleT context m (a -> b)
-> ExampleT context m a -> ExampleT context m b
$cliftA2 :: forall context (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> ExampleT context m a
-> ExampleT context m b
-> ExampleT context m c
liftA2 :: forall a b c.
(a -> b -> c)
-> ExampleT context m a
-> ExampleT context m b
-> ExampleT context m c
$c*> :: forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
*> :: forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
$c<* :: forall context (m :: * -> *) a b.
Applicative m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m a
<* :: forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m a
Applicative, Applicative (ExampleT context m)
Applicative (ExampleT context m) =>
(forall a b.
 ExampleT context m a
 -> (a -> ExampleT context m b) -> ExampleT context m b)
-> (forall a b.
    ExampleT context m a
    -> ExampleT context m b -> ExampleT context m b)
-> (forall a. a -> ExampleT context m a)
-> Monad (ExampleT context m)
forall a. a -> ExampleT context m a
forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
forall a b.
ExampleT context m a
-> (a -> ExampleT context m b) -> ExampleT context m b
forall context (m :: * -> *).
Monad m =>
Applicative (ExampleT context m)
forall context (m :: * -> *) a.
Monad m =>
a -> ExampleT context m a
forall context (m :: * -> *) a b.
Monad m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
forall context (m :: * -> *) a b.
Monad m =>
ExampleT context m a
-> (a -> ExampleT context m b) -> ExampleT context m b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall context (m :: * -> *) a b.
Monad m =>
ExampleT context m a
-> (a -> ExampleT context m b) -> ExampleT context m b
>>= :: forall a b.
ExampleT context m a
-> (a -> ExampleT context m b) -> ExampleT context m b
$c>> :: forall context (m :: * -> *) a b.
Monad m =>
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
>> :: forall a b.
ExampleT context m a
-> ExampleT context m b -> ExampleT context m b
$creturn :: forall context (m :: * -> *) a.
Monad m =>
a -> ExampleT context m a
return :: forall a. a -> ExampleT context m a
Monad, Monad (ExampleT context m)
Monad (ExampleT context m) =>
(forall a. IO a -> ExampleT context m a)
-> MonadIO (ExampleT context m)
forall a. IO a -> ExampleT context m a
forall context (m :: * -> *).
MonadIO m =>
Monad (ExampleT context m)
forall context (m :: * -> *) a.
MonadIO m =>
IO a -> ExampleT context m a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
$cliftIO :: forall context (m :: * -> *) a.
MonadIO m =>
IO a -> ExampleT context m a
liftIO :: forall a. IO a -> ExampleT context m a
MonadIO, MonadReader context, Monad (ExampleT context m)
Monad (ExampleT context m) =>
(forall msg.
 ToLogStr msg =>
 Loc -> LogSource -> LogLevel -> msg -> ExampleT context m ())
-> MonadLogger (ExampleT context m)
forall msg.
ToLogStr msg =>
Loc -> LogSource -> LogLevel -> msg -> ExampleT context m ()
forall context (m :: * -> *).
MonadIO m =>
Monad (ExampleT context m)
forall context (m :: * -> *) msg.
(MonadIO m, ToLogStr msg) =>
Loc -> LogSource -> LogLevel -> msg -> ExampleT context m ()
forall (m :: * -> *).
Monad m =>
(forall msg.
 ToLogStr msg =>
 Loc -> LogSource -> LogLevel -> msg -> m ())
-> MonadLogger m
$cmonadLoggerLog :: forall context (m :: * -> *) msg.
(MonadIO m, ToLogStr msg) =>
Loc -> LogSource -> LogLevel -> msg -> ExampleT context m ()
monadLoggerLog :: forall msg.
ToLogStr msg =>
Loc -> LogSource -> LogLevel -> msg -> ExampleT context m ()
MonadLogger, MonadIO (ExampleT context m)
MonadLogger (ExampleT context m)
ExampleT
  context m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
(MonadLogger (ExampleT context m), MonadIO (ExampleT context m)) =>
ExampleT
  context m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
-> MonadLoggerIO (ExampleT context m)
forall context (m :: * -> *).
MonadIO m =>
MonadIO (ExampleT context m)
forall context (m :: * -> *).
MonadIO m =>
MonadLogger (ExampleT context m)
forall context (m :: * -> *).
MonadIO m =>
ExampleT
  context m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
forall (m :: * -> *).
(MonadLogger m, MonadIO m) =>
m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
-> MonadLoggerIO m
$caskLoggerIO :: forall context (m :: * -> *).
MonadIO m =>
ExampleT
  context m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
askLoggerIO :: ExampleT
  context m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
MonadLoggerIO, Monad (ExampleT context m)
Monad (ExampleT context m) =>
(forall e a.
 (HasCallStack, Exception e) =>
 e -> ExampleT context m a)
-> MonadThrow (ExampleT context m)
forall e a.
(HasCallStack, Exception e) =>
e -> ExampleT context m a
forall context (m :: * -> *).
MonadThrow m =>
Monad (ExampleT context m)
forall context (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> ExampleT context m a
forall (m :: * -> *).
Monad m =>
(forall e a. (HasCallStack, Exception e) => e -> m a)
-> MonadThrow m
$cthrowM :: forall context (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> ExampleT context m a
throwM :: forall e a.
(HasCallStack, Exception e) =>
e -> ExampleT context m a
MonadThrow, MonadThrow (ExampleT context m)
MonadThrow (ExampleT context m) =>
(forall e a.
 (HasCallStack, Exception e) =>
 ExampleT context m a
 -> (e -> ExampleT context m a) -> ExampleT context m a)
-> MonadCatch (ExampleT context m)
forall e a.
(HasCallStack, Exception e) =>
ExampleT context m a
-> (e -> ExampleT context m a) -> ExampleT context m a
forall context (m :: * -> *).
MonadCatch m =>
MonadThrow (ExampleT context m)
forall context (m :: * -> *) e a.
(MonadCatch m, HasCallStack, Exception e) =>
ExampleT context m a
-> (e -> ExampleT context m a) -> ExampleT context m a
forall (m :: * -> *).
MonadThrow m =>
(forall e a.
 (HasCallStack, Exception e) =>
 m a -> (e -> m a) -> m a)
-> MonadCatch m
$ccatch :: forall context (m :: * -> *) e a.
(MonadCatch m, HasCallStack, Exception e) =>
ExampleT context m a
-> (e -> ExampleT context m a) -> ExampleT context m a
catch :: forall e a.
(HasCallStack, Exception e) =>
ExampleT context m a
-> (e -> ExampleT context m a) -> ExampleT context m a
MonadCatch, MonadCatch (ExampleT context m)
MonadCatch (ExampleT context m) =>
(forall b.
 HasCallStack =>
 ((forall a. ExampleT context m a -> ExampleT context m a)
  -> ExampleT context m b)
 -> ExampleT context m b)
-> (forall b.
    HasCallStack =>
    ((forall a. ExampleT context m a -> ExampleT context m a)
     -> ExampleT context m b)
    -> ExampleT context m b)
-> (forall a b c.
    HasCallStack =>
    ExampleT context m a
    -> (a -> ExitCase b -> ExampleT context m c)
    -> (a -> ExampleT context m b)
    -> ExampleT context m (b, c))
-> MonadMask (ExampleT context m)
forall b.
HasCallStack =>
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
forall a b c.
HasCallStack =>
ExampleT context m a
-> (a -> ExitCase b -> ExampleT context m c)
-> (a -> ExampleT context m b)
-> ExampleT context m (b, c)
forall context (m :: * -> *).
MonadMask m =>
MonadCatch (ExampleT context m)
forall context (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
forall context (m :: * -> *) a b c.
(MonadMask m, HasCallStack) =>
ExampleT context m a
-> (a -> ExitCase b -> ExampleT context m c)
-> (a -> ExampleT context m b)
-> ExampleT context m (b, c)
forall (m :: * -> *).
MonadCatch m =>
(forall b. HasCallStack => ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b.
    HasCallStack =>
    ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a b c.
    HasCallStack =>
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadMask m
$cmask :: forall context (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
mask :: forall b.
HasCallStack =>
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
$cuninterruptibleMask :: forall context (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
uninterruptibleMask :: forall b.
HasCallStack =>
((forall a. ExampleT context m a -> ExampleT context m a)
 -> ExampleT context m b)
-> ExampleT context m b
$cgeneralBracket :: forall context (m :: * -> *) a b c.
(MonadMask m, HasCallStack) =>
ExampleT context m a
-> (a -> ExitCase b -> ExampleT context m c)
-> (a -> ExampleT context m b)
-> ExampleT context m (b, c)
generalBracket :: forall a b c.
HasCallStack =>
ExampleT context m a
-> (a -> ExitCase b -> ExampleT context m c)
-> (a -> ExampleT context m b)
-> ExampleT context m (b, c)
MonadMask)
type ExampleM context = ExampleT context IO

deriving instance (Applicative m, Alternative (LoggingT m)) => Alternative (ExampleT context m)

instance (MonadIO m, MonadUnliftIO m) => MonadUnliftIO (ExampleT context m) where
  withRunInIO :: forall b.
((forall a. ExampleT context m a -> IO a) -> IO b)
-> ExampleT context m b
withRunInIO (forall a. ExampleT context m a -> IO a) -> IO b
inner = ReaderT context (LoggingT m) b -> ExampleT context m b
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT (ReaderT context (LoggingT m) b -> ExampleT context m b)
-> ReaderT context (LoggingT m) b -> ExampleT context m b
forall a b. (a -> b) -> a -> b
$ ((forall a. ReaderT context (LoggingT m) a -> IO a) -> IO b)
-> ReaderT context (LoggingT m) b
forall b.
((forall a. ReaderT context (LoggingT m) a -> IO a) -> IO b)
-> ReaderT context (LoggingT m) b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (((forall a. ReaderT context (LoggingT m) a -> IO a) -> IO b)
 -> ReaderT context (LoggingT m) b)
-> ((forall a. ReaderT context (LoggingT m) a -> IO a) -> IO b)
-> ReaderT context (LoggingT m) b
forall a b. (a -> b) -> a -> b
$ \forall a. ReaderT context (LoggingT m) a -> IO a
run -> (forall a. ExampleT context m a -> IO a) -> IO b
inner (ReaderT context (LoggingT m) a -> IO a
forall a. ReaderT context (LoggingT m) a -> IO a
run (ReaderT context (LoggingT m) a -> IO a)
-> (ExampleT context m a -> ReaderT context (LoggingT m) a)
-> ExampleT context m a
-> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExampleT context m a -> ReaderT context (LoggingT m) a
forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT)

instance (MonadBase b m) => MonadBase b (ExampleT context m) where
  liftBase :: forall α. b α -> ExampleT context m α
liftBase = b α -> ExampleT context m α
forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) α.
(MonadTrans t, MonadBase b m) =>
b α -> t m α
liftBaseDefault

instance MonadTrans (ExampleT context) where
  lift :: forall (m :: * -> *) a. Monad m => m a -> ExampleT context m a
lift m a
x = ReaderT context (LoggingT m) a -> ExampleT context m a
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT (ReaderT context (LoggingT m) a -> ExampleT context m a)
-> ReaderT context (LoggingT m) a -> ExampleT context m a
forall a b. (a -> b) -> a -> b
$ (context -> LoggingT m a) -> ReaderT context (LoggingT m) a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT (\context
_ -> (((Loc -> LogSource -> LogLevel -> LogStr -> IO ()) -> m a)
-> LoggingT m a
forall (m :: * -> *) a.
((Loc -> LogSource -> LogLevel -> LogStr -> IO ()) -> m a)
-> LoggingT m a
LoggingT (\Loc -> LogSource -> LogLevel -> LogStr -> IO ()
_ -> m a
x)))

instance MonadTransControl (ExampleT context) where
  type StT (ExampleT context) a = StT LoggingT (StT (ReaderT context) a)
  liftWith :: forall (m :: * -> *) a.
Monad m =>
(Run (ExampleT context) -> m a) -> ExampleT context m a
liftWith Run (ExampleT context) -> m a
f = (forall b. ReaderT context (LoggingT m) b -> ExampleT context m b)
-> (forall (o :: * -> *) b.
    ExampleT context o b -> ReaderT context (LoggingT o) b)
-> ((forall {m :: * -> *} {b}.
     (Monad m, Monad (LoggingT m)) =>
     ExampleT context m b -> m (StT LoggingT (StT (ReaderT context) b)))
    -> m a)
-> ExampleT context m a
forall (m :: * -> *) (n' :: (* -> *) -> * -> *)
       (n :: (* -> *) -> * -> *) (t :: (* -> *) -> * -> *) a.
(Monad m, Monad (n' m), MonadTransControl n,
 MonadTransControl n') =>
(forall b. n (n' m) b -> t m b)
-> (forall (o :: * -> *) b. t o b -> n (n' o) b)
-> (RunDefault2 t n n' -> m a)
-> t m a
defaultLiftWith2 ReaderT context (LoggingT m) b -> ExampleT context m b
forall b. ReaderT context (LoggingT m) b -> ExampleT context m b
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT ExampleT context o b -> ReaderT context (LoggingT o) b
forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
forall (o :: * -> *) b.
ExampleT context o b -> ReaderT context (LoggingT o) b
unExampleT (((forall {m :: * -> *} {b}.
   (Monad m, Monad (LoggingT m)) =>
   ExampleT context m b -> m (StT LoggingT (StT (ReaderT context) b)))
  -> m a)
 -> ExampleT context m a)
-> ((forall {m :: * -> *} {b}.
     (Monad m, Monad (LoggingT m)) =>
     ExampleT context m b -> m (StT LoggingT (StT (ReaderT context) b)))
    -> m a)
-> ExampleT context m a
forall a b. (a -> b) -> a -> b
$ \forall {m :: * -> *} {b}.
(Monad m, Monad (LoggingT m)) =>
ExampleT context m b -> m (StT LoggingT (StT (ReaderT context) b))
x -> Run (ExampleT context) -> m a
f ExampleT context n b -> n (StT LoggingT (StT (ReaderT context) b))
ExampleT context n b -> n (StT (ExampleT context) b)
forall {m :: * -> *} {b}.
(Monad m, Monad (LoggingT m)) =>
ExampleT context m b -> m (StT LoggingT (StT (ReaderT context) b))
Run (ExampleT context)
x
  restoreT :: forall (m :: * -> *) a.
Monad m =>
m (StT (ExampleT context) a) -> ExampleT context m a
restoreT = (ReaderT context (LoggingT m) a -> ExampleT context m a)
-> m (StT LoggingT (StT (ReaderT context) a))
-> ExampleT context m a
forall (m :: * -> *) (n' :: (* -> *) -> * -> *)
       (n :: (* -> *) -> * -> *) a (t :: (* -> *) -> * -> *).
(Monad m, Monad (n' m), MonadTransControl n,
 MonadTransControl n') =>
(n (n' m) a -> t m a) -> m (StT n' (StT n a)) -> t m a
defaultRestoreT2 ReaderT context (LoggingT m) a -> ExampleT context m a
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT

instance (MonadBaseControl b m) => MonadBaseControl b (ExampleT context m) where
  type StM (ExampleT context m) a = ComposeSt (ExampleT context) m a
  liftBaseWith :: forall a.
(RunInBase (ExampleT context m) b -> b a) -> ExampleT context m a
liftBaseWith = (RunInBaseDefault (ExampleT context) m b -> b a)
-> ExampleT context m a
(RunInBase (ExampleT context m) b -> b a) -> ExampleT context m a
forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) a.
(MonadTransControl t, MonadBaseControl b m) =>
(RunInBaseDefault t m b -> b a) -> t m a
defaultLiftBaseWith
  restoreM :: forall a. StM (ExampleT context m) a -> ExampleT context m a
restoreM = ComposeSt (ExampleT context) m a -> ExampleT context m a
StM (ExampleT context m) a -> ExampleT context m a
forall (t :: (* -> *) -> * -> *) (b :: * -> *) (m :: * -> *) a.
(MonadTransControl t, MonadBaseControl b m) =>
ComposeSt t m a -> t m a
defaultRestoreM

instance (Monad m, MonadThrow m) => MonadFail (ExampleT context m) where
  fail :: (HasCallStack) => String -> ExampleT context m a
  fail :: forall a. HasCallStack => String -> ExampleT context m a
fail = FailureReason -> ExampleT context m a
forall (m :: * -> *) e a.
(HasCallStack, MonadThrow m, Exception e) =>
e -> m a
throwIO (FailureReason -> ExampleT context m a)
-> (String -> FailureReason) -> String -> ExampleT context m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe CallStack -> String -> FailureReason
Reason (CallStack -> Maybe CallStack
forall a. a -> Maybe a
Just CallStack
HasCallStack => CallStack
callStack)

-- * Results

data Result = Success
            | Failure FailureReason
            | DryRun
            | Cancelled
  deriving (Int -> Result -> ShowS
[Result] -> ShowS
Result -> String
(Int -> Result -> ShowS)
-> (Result -> String) -> ([Result] -> ShowS) -> Show Result
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Result -> ShowS
showsPrec :: Int -> Result -> ShowS
$cshow :: Result -> String
show :: Result -> String
$cshowList :: [Result] -> ShowS
showList :: [Result] -> ShowS
Show, Result -> Result -> Bool
(Result -> Result -> Bool)
-> (Result -> Result -> Bool) -> Eq Result
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Result -> Result -> Bool
== :: Result -> Result -> Bool
$c/= :: Result -> Result -> Bool
/= :: Result -> Result -> Bool
Eq)

data ExtraTimingInfo = ExtraTimingInfo {
  ExtraTimingInfo -> Maybe NominalDiffTime
setupTime :: Maybe NominalDiffTime
  , ExtraTimingInfo -> Maybe NominalDiffTime
teardownTime :: Maybe NominalDiffTime
  }
emptyExtraTimingInfo :: ExtraTimingInfo
emptyExtraTimingInfo = Maybe NominalDiffTime -> Maybe NominalDiffTime -> ExtraTimingInfo
ExtraTimingInfo Maybe NominalDiffTime
forall a. Maybe a
Nothing Maybe NominalDiffTime
forall a. Maybe a
Nothing
mkSetupTimingInfo :: NominalDiffTime -> ExtraTimingInfo
mkSetupTimingInfo NominalDiffTime
dt = Maybe NominalDiffTime -> Maybe NominalDiffTime -> ExtraTimingInfo
ExtraTimingInfo (NominalDiffTime -> Maybe NominalDiffTime
forall a. a -> Maybe a
Just NominalDiffTime
dt) Maybe NominalDiffTime
forall a. Maybe a
Nothing
mkTeardownTimingInfo :: NominalDiffTime -> ExtraTimingInfo
mkTeardownTimingInfo NominalDiffTime
dt = Maybe NominalDiffTime -> Maybe NominalDiffTime -> ExtraTimingInfo
ExtraTimingInfo Maybe NominalDiffTime
forall a. Maybe a
Nothing (NominalDiffTime -> Maybe NominalDiffTime
forall a. a -> Maybe a
Just NominalDiffTime
dt)

data ShowEqBox = forall s. (Show s, Eq s) => SEB s
instance Show ShowEqBox where show :: ShowEqBox -> String
show (SEB s
x) = s -> String
forall a. Show a => a -> String
show s
x
instance Eq ShowEqBox where (SEB s
x1) == :: ShowEqBox -> ShowEqBox -> Bool
== (SEB s
x2) = s -> String
forall a. Show a => a -> String
show s
x1 String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== s -> String
forall a. Show a => a -> String
show s
x2

data FailureReason = Reason { FailureReason -> Maybe CallStack
failureCallStack :: Maybe CallStack
                            , FailureReason -> String
failureReason :: String }
                   | ExpectedButGot { failureCallStack :: Maybe CallStack
                                    , FailureReason -> ShowEqBox
failureValue1 :: ShowEqBox
                                    , FailureReason -> ShowEqBox
failureValue2 :: ShowEqBox }
                   | DidNotExpectButGot { failureCallStack :: Maybe CallStack
                                        , failureValue1 :: ShowEqBox }
                   | GotException { failureCallStack :: Maybe CallStack
                                  , FailureReason -> Maybe String
failureMessage :: Maybe String
                                  , FailureReason -> SomeExceptionWithEq
failureException :: SomeExceptionWithEq }
                   | Pending { failureCallStack :: Maybe CallStack
                             , FailureReason -> Maybe String
failurePendingMessage :: Maybe String }
                   | GetContextException { failureCallStack :: Maybe CallStack
                                         , failureException :: SomeExceptionWithEq }
                   | GotAsyncException { failureCallStack :: Maybe CallStack
                                       , failureMessage :: Maybe String
                                       , FailureReason -> SomeAsyncExceptionWithEq
failureAsyncException :: SomeAsyncExceptionWithEq }
                   | ChildrenFailed { failureCallStack :: Maybe CallStack
                                    , FailureReason -> Int
failureNumChildren :: Int }
                   | RawImage { failureCallStack :: Maybe CallStack
                              , FailureReason -> String
failureFallback :: String
                              , FailureReason -> Image
failureRawImage :: Image }
  deriving (Int -> FailureReason -> ShowS
[FailureReason] -> ShowS
FailureReason -> String
(Int -> FailureReason -> ShowS)
-> (FailureReason -> String)
-> ([FailureReason] -> ShowS)
-> Show FailureReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FailureReason -> ShowS
showsPrec :: Int -> FailureReason -> ShowS
$cshow :: FailureReason -> String
show :: FailureReason -> String
$cshowList :: [FailureReason] -> ShowS
showList :: [FailureReason] -> ShowS
Show, Typeable, FailureReason -> FailureReason -> Bool
(FailureReason -> FailureReason -> Bool)
-> (FailureReason -> FailureReason -> Bool) -> Eq FailureReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FailureReason -> FailureReason -> Bool
== :: FailureReason -> FailureReason -> Bool
$c/= :: FailureReason -> FailureReason -> Bool
/= :: FailureReason -> FailureReason -> Bool
Eq)

instance Exception FailureReason

instance Eq CallStack where
  CallStack
c1 == :: CallStack -> CallStack -> Bool
== CallStack
c2 = CallStack -> String
forall a. Show a => a -> String
show CallStack
c1 String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== CallStack -> String
forall a. Show a => a -> String
show CallStack
c2

newtype SomeExceptionWithEq = SomeExceptionWithEq SomeException
instance Show SomeExceptionWithEq where
  show :: SomeExceptionWithEq -> String
show (SomeExceptionWithEq SomeException
e) = SomeException -> String
forall a. Show a => a -> String
show SomeException
e
instance Eq SomeExceptionWithEq where
  (SomeExceptionWithEq SomeException
e1) == :: SomeExceptionWithEq -> SomeExceptionWithEq -> Bool
== (SomeExceptionWithEq SomeException
e2) = SomeException -> String
forall a. Show a => a -> String
show SomeException
e1 String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== SomeException -> String
forall a. Show a => a -> String
show SomeException
e2

newtype SomeAsyncExceptionWithEq = SomeAsyncExceptionWithEq SomeAsyncException
  deriving Int -> SomeAsyncExceptionWithEq -> ShowS
[SomeAsyncExceptionWithEq] -> ShowS
SomeAsyncExceptionWithEq -> String
(Int -> SomeAsyncExceptionWithEq -> ShowS)
-> (SomeAsyncExceptionWithEq -> String)
-> ([SomeAsyncExceptionWithEq] -> ShowS)
-> Show SomeAsyncExceptionWithEq
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SomeAsyncExceptionWithEq -> ShowS
showsPrec :: Int -> SomeAsyncExceptionWithEq -> ShowS
$cshow :: SomeAsyncExceptionWithEq -> String
show :: SomeAsyncExceptionWithEq -> String
$cshowList :: [SomeAsyncExceptionWithEq] -> ShowS
showList :: [SomeAsyncExceptionWithEq] -> ShowS
Show
instance Eq SomeAsyncExceptionWithEq where
  (SomeAsyncExceptionWithEq SomeAsyncException
e1) == :: SomeAsyncExceptionWithEq -> SomeAsyncExceptionWithEq -> Bool
== (SomeAsyncExceptionWithEq SomeAsyncException
e2) = SomeAsyncException -> String
forall a. Show a => a -> String
show SomeAsyncException
e1 String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== SomeAsyncException -> String
forall a. Show a => a -> String
show SomeAsyncException
e2

-- * Label stuff

data Label (l :: Symbol) a = Label

data LabelValue (l :: Symbol) a = LabelValue a

-- TODO: get rid of overlapping instance
-- Maybe look at https://kseo.github.io/posts/2017-02-05-avoid-overlapping-instances-with-closed-type-families.html
class HasLabel context (l :: Symbol) a where
  getLabelValue :: Label l a -> context -> a
instance HasLabel (LabelValue l a) l a where
  getLabelValue :: Label l a -> LabelValue l a -> a
getLabelValue Label l a
_ (LabelValue a
x) = a
x
instance {-# OVERLAPPING #-} HasLabel (LabelValue l a :> context) l a where
  getLabelValue :: Label l a -> (LabelValue l a :> context) -> a
getLabelValue Label l a
_ (LabelValue a
x :> context
_) = a
x
instance {-# OVERLAPPING #-} HasLabel context l a => HasLabel (intro :> context) l a where
  getLabelValue :: Label l a -> (intro :> context) -> a
getLabelValue Label l a
l (intro
_ :> context
ctx) = Label l a -> context -> a
forall context (l :: Symbol) a.
HasLabel context l a =>
Label l a -> context -> a
getLabelValue Label l a
l context
ctx


-- * Free monad language

data (a :: Type) :> (b :: Type) = a :> b
  deriving Int -> (a :> b) -> ShowS
[a :> b] -> ShowS
(a :> b) -> String
(Int -> (a :> b) -> ShowS)
-> ((a :> b) -> String) -> ([a :> b] -> ShowS) -> Show (a :> b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> (a :> b) -> ShowS
forall a b. (Show a, Show b) => [a :> b] -> ShowS
forall a b. (Show a, Show b) => (a :> b) -> String
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> (a :> b) -> ShowS
showsPrec :: Int -> (a :> b) -> ShowS
$cshow :: forall a b. (Show a, Show b) => (a :> b) -> String
show :: (a :> b) -> String
$cshowList :: forall a b. (Show a, Show b) => [a :> b] -> ShowS
showList :: [a :> b] -> ShowS
Show
infixr :>

type ActionWith a = a -> IO ()

data NodeModuleInfo = NodeModuleInfo {
  NodeModuleInfo -> String
nodeModuleInfoModuleName :: String
  , NodeModuleInfo -> Maybe (IO ())
nodeModuleInfoFn :: Maybe (IO ())
  }

instance Show NodeModuleInfo where
  show :: NodeModuleInfo -> String
show (NodeModuleInfo {String
Maybe (IO ())
nodeModuleInfoModuleName :: NodeModuleInfo -> String
nodeModuleInfoFn :: NodeModuleInfo -> Maybe (IO ())
nodeModuleInfoModuleName :: String
nodeModuleInfoFn :: Maybe (IO ())
..}) = [i|#{nodeModuleInfoModuleName}<Has main? #{isJust nodeModuleInfoFn}>|]

-- | Options for an individual test node.
data NodeOptions = NodeOptions {
  NodeOptions -> Int
nodeOptionsVisibilityThreshold :: Int
  -- ^ The visibility threshold of the node. See the main docs for an explanation of this.
  , NodeOptions -> Bool
nodeOptionsCreateFolder :: Bool
  -- ^ Whether to create a folder in the on-disk test results for this node.
  -- Defaults to 'True', but can be turned off to reduce extraneous folders from nodes like 'Parallel'.
  , NodeOptions -> Bool
nodeOptionsRecordTime :: Bool
  -- ^ Whether to time this node.
  , NodeOptions -> Maybe NodeModuleInfo
nodeOptionsModuleInfo :: Maybe NodeModuleInfo
  -- ^ A main function run this entire node in isolation.
  } deriving Int -> NodeOptions -> ShowS
[NodeOptions] -> ShowS
NodeOptions -> String
(Int -> NodeOptions -> ShowS)
-> (NodeOptions -> String)
-> ([NodeOptions] -> ShowS)
-> Show NodeOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NodeOptions -> ShowS
showsPrec :: Int -> NodeOptions -> ShowS
$cshow :: NodeOptions -> String
show :: NodeOptions -> String
$cshowList :: [NodeOptions] -> ShowS
showList :: [NodeOptions] -> ShowS
Show

-- | Reasonable default node options.
defaultNodeOptions :: NodeOptions
defaultNodeOptions :: NodeOptions
defaultNodeOptions = Int -> Bool -> Bool -> Maybe NodeModuleInfo -> NodeOptions
NodeOptions Int
100 Bool
True Bool
True Maybe NodeModuleInfo
forall a. Maybe a
Nothing

data SpecCommand context m next where
  Before'' :: {
    forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
location :: Maybe SrcLoc
    , forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
nodeOptions :: NodeOptions
    , forall context (m :: * -> *) next.
SpecCommand context m next -> String
label :: String
    , forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
action :: ExampleT context m ()
    , forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
subspec :: SpecFree context m ()
    , forall context (m :: * -> *) next.
SpecCommand context m next -> next
next :: next
    } -> SpecCommand context m next

  After'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , action :: ExampleT context m ()
    , subspec :: SpecFree context m ()
    , next :: next
    } -> SpecCommand context m next

  Introduce'' :: (Typeable intro) => {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , ()
contextLabel :: Label l intro
    , ()
allocate :: ExampleT context m intro
    , ()
cleanup :: intro -> ExampleT context m ()
    , ()
subspecAugmented :: SpecFree (LabelValue l intro :> context) m ()
    , next :: next
    } -> SpecCommand context m next

  IntroduceWith'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , contextLabel :: Label l intro
    , ()
introduceAction :: (intro -> ExampleT context m [Result]) -> ExampleT context m ()
    , subspecAugmented :: SpecFree (LabelValue l intro :> context) m ()
    , next :: next
    } -> SpecCommand context m next

  Around'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
    , subspec :: SpecFree context m ()
    , next :: next
    } -> SpecCommand context m next

  Describe'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , label :: String
    , subspec :: SpecFree context m ()
    , next :: next
    } -> SpecCommand context m next

  Parallel'' :: {
    location :: Maybe SrcLoc
    , nodeOptions :: NodeOptions
    , subspec :: SpecFree context m ()
    , next :: next
    } -> SpecCommand context m next

  It'' :: { location :: Maybe SrcLoc
          , nodeOptions :: NodeOptions
          , label :: String
          , forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
example :: ExampleT context m ()
          , next :: next } -> SpecCommand context m next

deriving instance Functor (SpecCommand context m)
deriving instance Foldable (SpecCommand context m)
deriving instance Traversable (SpecCommand context m)


type Spec context m = SpecFree context m ()
type SpecFree context m a = Free (SpecCommand context m) a

makeFree_ ''SpecCommand

instance Show t => Show (SpecCommand context m t) where
  showsPrec :: Int -> SpecCommand context m t -> ShowS
showsPrec = (Int -> t -> ShowS)
-> ([t] -> ShowS) -> Int -> SpecCommand context m t -> ShowS
forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> SpecCommand context m a -> ShowS
forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
liftShowsPrec Int -> t -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec [t] -> ShowS
forall a. Show a => [a] -> ShowS
showList

instance Show1 (SpecCommand context m) where
  liftShowsPrec :: forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> SpecCommand context m a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Before'' {a
String
Maybe SrcLoc
SpecFree context m ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
action :: ExampleT context m ()
subspec :: SpecFree context m ()
next :: a
..}) = (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Before[#{label}]<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (After'' {a
String
Maybe SrcLoc
SpecFree context m ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
action :: ExampleT context m ()
subspec :: SpecFree context m ()
next :: a
..}) = (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|After[#{label}]<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Introduce'' {a
String
Maybe SrcLoc
SpecFree (LabelValue l intro :> context) m ()
NodeOptions
Label l intro
ExampleT context m intro
intro -> ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
contextLabel :: ()
allocate :: ()
cleanup :: ()
subspecAugmented :: ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
contextLabel :: Label l intro
allocate :: ExampleT context m intro
cleanup :: intro -> ExampleT context m ()
subspecAugmented :: SpecFree (LabelValue l intro :> context) m ()
next :: a
..}) = (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Introduce[#{label}]<#{show subspecAugmented}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (IntroduceWith'' {a
String
Maybe SrcLoc
SpecFree (LabelValue l intro :> context) m ()
NodeOptions
Label l intro
(intro -> ExampleT context m [Result]) -> ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
contextLabel :: ()
subspecAugmented :: ()
introduceAction :: ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
contextLabel :: Label l intro
introduceAction :: (intro -> ExampleT context m [Result]) -> ExampleT context m ()
subspecAugmented :: SpecFree (LabelValue l intro :> context) m ()
next :: a
..}) = (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|IntroduceWith[#{label}]<#{show subspecAugmented}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Around'' {a
String
Maybe SrcLoc
SpecFree context m ()
NodeOptions
ExampleT context m [Result] -> ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
actionWith :: forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
subspec :: SpecFree context m ()
next :: a
..}) = (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Around[#{label}]<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Describe'' {a
String
Maybe SrcLoc
SpecFree context m ()
NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
subspec :: SpecFree context m ()
next :: a
..}) = (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Describe[#{label}]<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Parallel'' {a
Maybe SrcLoc
SpecFree context m ()
NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
subspec :: SpecFree context m ()
next :: a
..}) = (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|Parallel<#{show subspec}>|] Int
d a
next
  liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (It'' {a
String
Maybe SrcLoc
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
example :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
example :: ExampleT context m ()
next :: a
..}) = (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp [i|It[#{label}]|] Int
d a
next

-- * ----------------------------------------------------------

-- | Perform an action before a given spec tree.
before :: (HasCallStack) =>
  String
  -- ^ Label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
before :: forall context (m :: * -> *).
HasCallStack =>
String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
before = NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
before' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 100 })

-- | Perform an action before a given spec tree.
before' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
before' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
before' = Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
before'' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (Int -> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a. Int -> [a] -> [a]
drop Int
1 ([(String, SrcLoc)] -> [(String, SrcLoc)])
-> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack))

-- | Perform an action before a given spec tree.
before'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Perform an action after a given spec tree.
after :: (HasCallStack) =>
  String
  -- ^ Label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
after :: forall context (m :: * -> *).
HasCallStack =>
String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
after = NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
after' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 100 })

-- | Perform an action after a given spec tree.
after' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
after' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
after' = Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
after'' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (Int -> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a. Int -> [a] -> [a]
drop Int
1 ([(String, SrcLoc)] -> [(String, SrcLoc)])
-> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack))

-- | Perform an action after a given spec tree.
after'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> ExampleT context m ()
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Introduce a new value and make it available to the child spec tree.
introduce :: (HasCallStack, Typeable intro) =>
  String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ExampleT context m intro
  -- ^ Action to produce the new value (of type 'intro')
  -> (intro -> ExampleT context m ())
  -- ^ Action to clean up the new value
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
introduce :: forall intro (l :: Symbol) context (m :: * -> *).
(HasCallStack, Typeable intro) =>
String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduce = NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
forall intro (l :: Symbol) context (m :: * -> *).
(HasCallStack, Typeable intro) =>
NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduce' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 100 })

-- | Introduce a new value and make it available to the child spec tree.
introduce' :: (HasCallStack, Typeable intro) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ExampleT context m intro
  -- ^ Action to produce the new value (of type 'intro')
  -> (intro -> ExampleT context m ())
  -- ^ Action to clean up the new value
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
introduce' :: forall intro (l :: Symbol) context (m :: * -> *).
(HasCallStack, Typeable intro) =>
NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduce' = Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
forall intro (l :: Symbol) context (m :: * -> *).
(HasCallStack, Typeable intro) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduce'' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (Int -> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a. Int -> [a] -> [a]
drop Int
1 ([(String, SrcLoc)] -> [(String, SrcLoc)])
-> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack))

-- | Introduce a new value and make it available to the child spec tree.
introduce'' :: (HasCallStack, Typeable intro) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ExampleT context m intro
  -- ^ Action to produce the new value (of type 'intro')
  -> (intro -> ExampleT context m ())
  -- ^ Action to clean up the new value
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Introduce a new value in an 'around' fashion, so it can be used with context managers like withFile or bracket.
introduceWith :: (HasCallStack) =>
  String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ((intro -> ExampleT context m [Result]) -> ExampleT context m ())
  -- ^ Callback to receive the new value and the child tree.
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
introduceWith :: forall (l :: Symbol) intro context (m :: * -> *).
HasCallStack =>
String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduceWith = NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
forall (l :: Symbol) intro context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduceWith' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 100 })

-- | Introduce a new value in an 'around' fashion, so it can be used with context managers like withFile or bracket.
introduceWith' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ((intro -> ExampleT context m [Result]) -> ExampleT context m ())
  -- ^ Callback to receive the new value and the child tree.
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
introduceWith' :: forall (l :: Symbol) intro context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduceWith' = Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
forall (l :: Symbol) intro context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree context m ()
introduceWith'' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (Int -> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a. Int -> [a] -> [a]
drop Int
1 ([(String, SrcLoc)] -> [(String, SrcLoc)])
-> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack))

-- | Introduce a new value in an 'around' fashion, so it can be used with context managers like withFile or bracket.
introduceWith'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> Label l intro
  -- ^ 'Label' under which to introduce the value
  -> ((intro -> ExampleT context m [Result]) -> ExampleT context m ())
  -- ^ Callback to receive the new value and the child tree.
  -> SpecFree (LabelValue l intro :> context) m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Run an action around the given child subtree. Useful for context managers like withFile or bracket.
around :: (HasCallStack) =>
  String
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
around :: forall context (m :: * -> *).
HasCallStack =>
String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
around = NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
around' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 100 })

-- | Run an action around the given child subtree. Useful for context managers like withFile or bracket.
around' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
around' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
around' = Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
around'' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (Int -> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a. Int -> [a] -> [a]
drop Int
1 ([(String, SrcLoc)] -> [(String, SrcLoc)])
-> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack))

-- | Run an action around the given child subtree. Useful for context managers like withFile or bracket.
around'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this node
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()


-- * ----------------------------------------------------------

-- | Define a group of tests.
describe :: (HasCallStack) =>
  String
  -- ^ Label for this group
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
describe :: forall context (m :: * -> *).
HasCallStack =>
String -> SpecFree context m () -> SpecFree context m ()
describe = NodeOptions
-> String -> SpecFree context m () -> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String -> SpecFree context m () -> SpecFree context m ()
describe' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 50 })

-- | Define a group of tests.
describe' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ Label for this group
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
describe' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String -> SpecFree context m () -> SpecFree context m ()
describe' = Maybe SrcLoc
-> NodeOptions
-> String
-> SpecFree context m ()
-> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> SpecFree context m ()
-> SpecFree context m ()
describe'' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (Int -> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a. Int -> [a] -> [a]
drop Int
1 ([(String, SrcLoc)] -> [(String, SrcLoc)])
-> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack))

-- | Define a group of tests.
describe'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ Label for this group
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Run a group of tests in parallel.
parallel :: (HasCallStack) =>
  SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
parallel :: forall context (m :: * -> *).
HasCallStack =>
SpecFree context m () -> SpecFree context m ()
parallel = NodeOptions -> SpecFree context m () -> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
NodeOptions -> SpecFree context m () -> SpecFree context m ()
parallel' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 70 })

-- | Run a group of tests in parallel.
parallel' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
parallel' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions -> SpecFree context m () -> SpecFree context m ()
parallel' = Maybe SrcLoc
-> NodeOptions -> SpecFree context m () -> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions -> SpecFree context m () -> SpecFree context m ()
parallel'' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (Int -> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a. Int -> [a] -> [a]
drop Int
1 ([(String, SrcLoc)] -> [(String, SrcLoc)])
-> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack))

-- | Run a group of tests in parallel.
parallel'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()

-- * ----------------------------------------------------------

-- | Define a single test example.
it :: (HasCallStack) =>
  String
  -- ^ Label for the example.
  -> ExampleT context m ()
  -- ^ The test example
  -> Free (SpecCommand context m) ()
it :: forall context (m :: * -> *).
HasCallStack =>
String -> ExampleT context m () -> Free (SpecCommand context m) ()
it = NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
it' (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 0 })

-- | Define a single test example.
it' :: (HasCallStack) =>
  NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for the example.
  -> ExampleT context m ()
  -- ^ The test example
  -> Free (SpecCommand context m) ()
it' :: forall context (m :: * -> *).
HasCallStack =>
NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
it' = Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
it'' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (Int -> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a. Int -> [a] -> [a]
drop Int
1 ([(String, SrcLoc)] -> [(String, SrcLoc)])
-> [(String, SrcLoc)] -> [(String, SrcLoc)]
forall a b. (a -> b) -> a -> b
$ CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack))

-- | Define a single test example.
it'' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for the example.
  -> ExampleT context m ()
  -- ^ The test example
  -> Free (SpecCommand context m) ()

-- * ----------------------------------------------------------

-- | Same as 'before', but applied individually to every 'it' node.
beforeEach :: (HasCallStack) =>
  String
  -- ^ String label for this context manager
  -> (ExampleT context m ())
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
beforeEach :: forall context (m :: * -> *).
HasCallStack =>
String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach = Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack)) (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 100 })

-- | Perform an action before each example in a given spec tree.
beforeEach' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> (ExampleT context m ())
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
beforeEach' :: forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Before'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
action :: ExampleT context m ()
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = beforeEach' loc no l f subspec, next = beforeEach' loc no l f next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(After'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
action :: ExampleT context m ()
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = beforeEach' loc no l f subspec, next = beforeEach' loc no l f next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Around'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m [Result] -> ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
actionWith :: forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = beforeEach' loc no l f subspec, next = beforeEach' loc no l f next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Describe'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = beforeEach' loc no l f subspec, next = beforeEach' loc no l f next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Parallel'' {Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = beforeEach' loc no l f subspec, next = beforeEach' loc no l f next })
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(It'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
example :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
example :: ExampleT context m ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
-> SpecCommand context m (Free (SpecCommand context m) ())
forall context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> next
-> SpecCommand context m next
Before'' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { next = Pure () })) (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free (Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> Free (SpecCommand context m) ()
-> SpecCommand context m (Free (SpecCommand context m) ())
forall l (intro :: Symbol) context (m :: * -> *) next.
Typeable l =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label intro l
-> ExampleT context m l
-> (l -> ExampleT context m ())
-> SpecFree (LabelValue intro l :> context) m ()
-> next
-> SpecCommand context m next
Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT (LabelValue l intro :> context) m ()
f' SpecFree (LabelValue l intro :> context) m ()
subspec) (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
  where f' :: ExampleT (LabelValue l intro :> context) m ()
f' = ReaderT (LabelValue l intro :> context) (LoggingT m) ()
-> ExampleT (LabelValue l intro :> context) m ()
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT (ReaderT (LabelValue l intro :> context) (LoggingT m) ()
 -> ExampleT (LabelValue l intro :> context) m ())
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
-> ExampleT (LabelValue l intro :> context) m ()
forall a b. (a -> b) -> a -> b
$ ((LabelValue l intro :> context) -> context)
-> ReaderT context (LoggingT m) ()
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(LabelValue l intro
_ :> context
context) -> context
context) (ReaderT context (LoggingT m) ()
 -> ReaderT (LabelValue l intro :> context) (LoggingT m) ())
-> ReaderT context (LoggingT m) ()
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
forall a b. (a -> b) -> a -> b
$ ExampleT context m () -> ReaderT context (LoggingT m) ()
forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT ExampleT context m ()
f
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free (IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> Free (SpecCommand context m) ()
-> SpecCommand context m (Free (SpecCommand context m) ())
forall (l :: Symbol) intro context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> next
-> SpecCommand context m next
IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT (LabelValue l intro :> context) m ()
f' SpecFree (LabelValue l intro :> context) m ()
subspec) (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
beforeEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
  where f' :: ExampleT (LabelValue l intro :> context) m ()
f' = ReaderT (LabelValue l intro :> context) (LoggingT m) ()
-> ExampleT (LabelValue l intro :> context) m ()
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT (ReaderT (LabelValue l intro :> context) (LoggingT m) ()
 -> ExampleT (LabelValue l intro :> context) m ())
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
-> ExampleT (LabelValue l intro :> context) m ()
forall a b. (a -> b) -> a -> b
$ ((LabelValue l intro :> context) -> context)
-> ReaderT context (LoggingT m) ()
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(LabelValue l intro
_ :> context
context) -> context
context) (ReaderT context (LoggingT m) ()
 -> ReaderT (LabelValue l intro :> context) (LoggingT m) ())
-> ReaderT context (LoggingT m) ()
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
forall a b. (a -> b) -> a -> b
$ ExampleT context m () -> ReaderT context (LoggingT m) ()
forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT ExampleT context m ()
f
beforeEach' Maybe SrcLoc
_ NodeOptions
_ String
_ ExampleT context m ()
_ (Pure ()
x) = () -> Free (SpecCommand context m) ()
forall (f :: * -> *) a. a -> Free f a
Pure ()
x

-- * ----------------------------------------------------------

-- | Same as 'after', but applied individually to every 'it' node.
afterEach :: (HasCallStack) =>
  String
  -- ^ String label for this context manager
  -> (ExampleT context m ())
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
afterEach :: forall context (m :: * -> *).
HasCallStack =>
String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach = Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack)) (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 100 })

-- | Perform an action after each example in a given spec tree.
afterEach' :: (HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ Label for this context manager
  -> (ExampleT context m ())
  -- ^ Action to perform
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
afterEach' :: forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Before'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
action :: ExampleT context m ()
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = afterEach' loc no l f subspec, next = afterEach' loc no l f next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(After'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
action :: ExampleT context m ()
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = afterEach' loc no l f subspec, next = afterEach' loc no l f next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Around'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m [Result] -> ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
actionWith :: forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = afterEach' loc no l f subspec, next = afterEach' loc no l f next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Describe'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = afterEach' loc no l f subspec, next = afterEach' loc no l f next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Parallel'' {Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = afterEach' loc no l f subspec, next = afterEach' loc no l f next })
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(It'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
example :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
example :: ExampleT context m ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
-> SpecCommand context m (Free (SpecCommand context m) ())
forall context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> next
-> SpecCommand context m next
After'' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { next = Pure () })) (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free (Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> Free (SpecCommand context m) ()
-> SpecCommand context m (Free (SpecCommand context m) ())
forall l (intro :: Symbol) context (m :: * -> *) next.
Typeable l =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label intro l
-> ExampleT context m l
-> (l -> ExampleT context m ())
-> SpecFree (LabelValue intro l :> context) m ()
-> next
-> SpecCommand context m next
Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT (LabelValue l intro :> context) m ()
f' SpecFree (LabelValue l intro :> context) m ()
subspec) (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
  where f' :: ExampleT (LabelValue l intro :> context) m ()
f' = ReaderT (LabelValue l intro :> context) (LoggingT m) ()
-> ExampleT (LabelValue l intro :> context) m ()
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT (ReaderT (LabelValue l intro :> context) (LoggingT m) ()
 -> ExampleT (LabelValue l intro :> context) m ())
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
-> ExampleT (LabelValue l intro :> context) m ()
forall a b. (a -> b) -> a -> b
$ ((LabelValue l intro :> context) -> context)
-> ReaderT context (LoggingT m) ()
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(LabelValue l intro
_ :> context
context) -> context
context) (ReaderT context (LoggingT m) ()
 -> ReaderT (LabelValue l intro :> context) (LoggingT m) ())
-> ReaderT context (LoggingT m) ()
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
forall a b. (a -> b) -> a -> b
$ ExampleT context m () -> ReaderT context (LoggingT m) ()
forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT ExampleT context m ()
f
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f (Free (IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> Free (SpecCommand context m) ()
-> SpecCommand context m (Free (SpecCommand context m) ())
forall (l :: Symbol) intro context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> next
-> SpecCommand context m next
IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT (LabelValue l intro :> context) m ()
f' SpecFree (LabelValue l intro :> context) m ()
subspec) (Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
forall context (m :: * -> *).
HasCallStack =>
Maybe SrcLoc
-> NodeOptions
-> String
-> ExampleT context m ()
-> SpecFree context m ()
-> SpecFree context m ()
afterEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m ()
f Free (SpecCommand context m) ()
next))
  where f' :: ExampleT (LabelValue l intro :> context) m ()
f' = ReaderT (LabelValue l intro :> context) (LoggingT m) ()
-> ExampleT (LabelValue l intro :> context) m ()
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT (ReaderT (LabelValue l intro :> context) (LoggingT m) ()
 -> ExampleT (LabelValue l intro :> context) m ())
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
-> ExampleT (LabelValue l intro :> context) m ()
forall a b. (a -> b) -> a -> b
$ ((LabelValue l intro :> context) -> context)
-> ReaderT context (LoggingT m) ()
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(LabelValue l intro
_ :> context
context) -> context
context) (ReaderT context (LoggingT m) ()
 -> ReaderT (LabelValue l intro :> context) (LoggingT m) ())
-> ReaderT context (LoggingT m) ()
-> ReaderT (LabelValue l intro :> context) (LoggingT m) ()
forall a b. (a -> b) -> a -> b
$ ExampleT context m () -> ReaderT context (LoggingT m) ()
forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT ExampleT context m ()
f
afterEach' Maybe SrcLoc
_ NodeOptions
_ String
_ ExampleT context m ()
_ (Pure ()
x) = () -> Free (SpecCommand context m) ()
forall (f :: * -> *) a. a -> Free f a
Pure ()
x

-- * ----------------------------------------------------------

-- | Same as 'around', but applied individually to every 'it' node.
aroundEach :: (Monad m, HasCallStack) =>
  String
  -- ^ String label for this context manager
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
aroundEach :: forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach = Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' ((String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd ((String, SrcLoc) -> SrcLoc)
-> Maybe (String, SrcLoc) -> Maybe SrcLoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(String, SrcLoc)] -> Maybe (String, SrcLoc)
forall a. [a] -> Maybe a
headMay (CallStack -> [(String, SrcLoc)]
getCallStack CallStack
HasCallStack => CallStack
callStack)) (NodeOptions
defaultNodeOptions { nodeOptionsVisibilityThreshold = 100 })

aroundEach' :: (Monad m, HasCallStack) =>
  Maybe SrcLoc
  -- ^ Location of this call
  -> NodeOptions
  -- ^ Custom options for this node
  -> String
  -- ^ String label for this context manager
  -> (ExampleT context m [Result] -> ExampleT context m ())
  -- ^ Callback to run the child tree
  -> SpecFree context m ()
  -- ^ Child spec tree
  -> SpecFree context m ()
aroundEach' :: forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Before'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
action :: ExampleT context m ()
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = aroundEach' loc no l f subspec, next = aroundEach' loc no l f next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(After'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
action :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
action :: ExampleT context m ()
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = aroundEach' loc no l f subspec, next = aroundEach' loc no l f next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Around'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m [Result] -> ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
actionWith :: forall context (m :: * -> *) next.
SpecCommand context m next
-> ExampleT context m [Result] -> ExampleT context m ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
actionWith :: ExampleT context m [Result] -> ExampleT context m ()
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = aroundEach' loc no l f subspec, next = aroundEach' loc no l f next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Describe'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = aroundEach' loc no l f subspec, next = aroundEach' loc no l f next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(Parallel'' {Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
subspec :: forall context (m :: * -> *) next.
SpecCommand context m next -> SpecFree context m ()
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
subspec :: Free (SpecCommand context m) ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { subspec = aroundEach' loc no l f subspec, next = aroundEach' loc no l f next })
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free x :: SpecCommand context m (Free (SpecCommand context m) ())
x@(It'' {String
Maybe SrcLoc
Free (SpecCommand context m) ()
NodeOptions
ExampleT context m ()
location :: forall context (m :: * -> *) next.
SpecCommand context m next -> Maybe SrcLoc
nodeOptions :: forall context (m :: * -> *) next.
SpecCommand context m next -> NodeOptions
label :: forall context (m :: * -> *) next.
SpecCommand context m next -> String
next :: forall context (m :: * -> *) next.
SpecCommand context m next -> next
example :: forall context (m :: * -> *) next.
SpecCommand context m next -> ExampleT context m ()
location :: Maybe SrcLoc
nodeOptions :: NodeOptions
label :: String
example :: ExampleT context m ()
next :: Free (SpecCommand context m) ()
..})) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
-> SpecCommand context m (Free (SpecCommand context m) ())
forall context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> next
-> SpecCommand context m next
Around'' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context m (Free (SpecCommand context m) ())
x { next = Pure () })) (Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next))
aroundEach' Maybe SrcLoc
_no NodeOptions
_ String
_ ExampleT context m [Result] -> ExampleT context m ()
_ (Pure ()
x) = () -> Free (SpecCommand context m) ()
forall (f :: * -> *) a. a -> Free f a
Pure ()
x
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free (IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> Free (SpecCommand context m) ()
-> SpecCommand context m (Free (SpecCommand context m) ())
forall (l :: Symbol) intro context (m :: * -> *) next.
Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ((intro -> ExampleT context m [Result])
    -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> next
-> SpecCommand context m next
IntroduceWith'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl (intro -> ExampleT context m [Result]) -> ExampleT context m ()
action (Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT (LabelValue l intro :> context) m [Result]
    -> ExampleT (LabelValue l intro :> context) m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ((ExampleT context m [Result] -> ExampleT context m ())
-> ExampleT (LabelValue l intro :> context) m [Result]
-> ExampleT (LabelValue l intro :> context) m ()
forall (m :: * -> *) introduce context.
Monad m =>
(ExampleT context m [Result] -> ExampleT context m ())
-> ExampleT (introduce :> context) m [Result]
-> ExampleT (introduce :> context) m ()
unwrapContext ExampleT context m [Result] -> ExampleT context m ()
f) SpecFree (LabelValue l intro :> context) m ()
subspec) (Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next))
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f (Free (Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean SpecFree (LabelValue l intro :> context) m ()
subspec Free (SpecCommand context m) ()
next)) = SpecCommand context m (Free (SpecCommand context m) ())
-> Free (SpecCommand context m) ()
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (Maybe SrcLoc
-> NodeOptions
-> String
-> Label l intro
-> ExampleT context m intro
-> (intro -> ExampleT context m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> Free (SpecCommand context m) ()
-> SpecCommand context m (Free (SpecCommand context m) ())
forall l (intro :: Symbol) context (m :: * -> *) next.
Typeable l =>
Maybe SrcLoc
-> NodeOptions
-> String
-> Label intro l
-> ExampleT context m l
-> (l -> ExampleT context m ())
-> SpecFree (LabelValue intro l :> context) m ()
-> next
-> SpecCommand context m next
Introduce'' Maybe SrcLoc
loci NodeOptions
noi String
li Label l intro
cl ExampleT context m intro
alloc intro -> ExampleT context m ()
clean (Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT (LabelValue l intro :> context) m [Result]
    -> ExampleT (LabelValue l intro :> context) m ())
-> SpecFree (LabelValue l intro :> context) m ()
-> SpecFree (LabelValue l intro :> context) m ()
forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ((ExampleT context m [Result] -> ExampleT context m ())
-> ExampleT (LabelValue l intro :> context) m [Result]
-> ExampleT (LabelValue l intro :> context) m ()
forall (m :: * -> *) introduce context.
Monad m =>
(ExampleT context m [Result] -> ExampleT context m ())
-> ExampleT (introduce :> context) m [Result]
-> ExampleT (introduce :> context) m ()
unwrapContext ExampleT context m [Result] -> ExampleT context m ()
f) SpecFree (LabelValue l intro :> context) m ()
subspec) (Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> Free (SpecCommand context m) ()
-> Free (SpecCommand context m) ()
forall (m :: * -> *) context.
(Monad m, HasCallStack) =>
Maybe SrcLoc
-> NodeOptions
-> String
-> (ExampleT context m [Result] -> ExampleT context m ())
-> SpecFree context m ()
-> SpecFree context m ()
aroundEach' Maybe SrcLoc
loc NodeOptions
no String
l ExampleT context m [Result] -> ExampleT context m ()
f Free (SpecCommand context m) ()
next))

-- * ----------------------------------------------------------

unwrapContext :: forall m introduce context. (Monad m) => (ExampleT context m [Result] -> ExampleT context m ()) -> ExampleT (introduce :> context) m [Result] -> ExampleT (introduce :> context) m ()
unwrapContext :: forall (m :: * -> *) introduce context.
Monad m =>
(ExampleT context m [Result] -> ExampleT context m ())
-> ExampleT (introduce :> context) m [Result]
-> ExampleT (introduce :> context) m ()
unwrapContext ExampleT context m [Result] -> ExampleT context m ()
f (ExampleT ReaderT (introduce :> context) (LoggingT m) [Result]
action) = do
  introduce
i :> context
_ <- ExampleT (introduce :> context) m (introduce :> context)
forall r (m :: * -> *). MonadReader r m => m r
ask
  ReaderT (introduce :> context) (LoggingT m) ()
-> ExampleT (introduce :> context) m ()
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT (ReaderT (introduce :> context) (LoggingT m) ()
 -> ExampleT (introduce :> context) m ())
-> ReaderT (introduce :> context) (LoggingT m) ()
-> ExampleT (introduce :> context) m ()
forall a b. (a -> b) -> a -> b
$ ((introduce :> context) -> context)
-> ReaderT context (LoggingT m) ()
-> ReaderT (introduce :> context) (LoggingT m) ()
forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (\(introduce
_ :> context
context) -> context
context) (ReaderT context (LoggingT m) ()
 -> ReaderT (introduce :> context) (LoggingT m) ())
-> ReaderT context (LoggingT m) ()
-> ReaderT (introduce :> context) (LoggingT m) ()
forall a b. (a -> b) -> a -> b
$ ExampleT context m () -> ReaderT context (LoggingT m) ()
forall context (m :: * -> *) a.
ExampleT context m a -> ReaderT context (LoggingT m) a
unExampleT (ExampleT context m () -> ReaderT context (LoggingT m) ())
-> ExampleT context m () -> ReaderT context (LoggingT m) ()
forall a b. (a -> b) -> a -> b
$ ExampleT context m [Result] -> ExampleT context m ()
f (ExampleT context m [Result] -> ExampleT context m ())
-> ExampleT context m [Result] -> ExampleT context m ()
forall a b. (a -> b) -> a -> b
$ ReaderT context (LoggingT m) [Result]
-> ExampleT context m [Result]
forall context (m :: * -> *) a.
ReaderT context (LoggingT m) a -> ExampleT context m a
ExampleT ((context -> introduce :> context)
-> ReaderT (introduce :> context) (LoggingT m) [Result]
-> ReaderT context (LoggingT m) [Result]
forall r' r (m :: * -> *) a.
(r' -> r) -> ReaderT r m a -> ReaderT r' m a
withReaderT (introduce
i introduce -> context -> introduce :> context
forall a b. a -> b -> a :> b
:>) ReaderT (introduce :> context) (LoggingT m) [Result]
action)


-- | Convert a spec to a run tree
alterTopLevelNodeOptions :: (NodeOptions -> NodeOptions) -> Free (SpecCommand context IO) r -> Free (SpecCommand context IO) r
alterTopLevelNodeOptions :: forall context r.
(NodeOptions -> NodeOptions)
-> Free (SpecCommand context IO) r
-> Free (SpecCommand context IO) r
alterTopLevelNodeOptions NodeOptions -> NodeOptions
g (Free SpecCommand context IO (Free (SpecCommand context IO) r)
x) = SpecCommand context IO (Free (SpecCommand context IO) r)
-> Free (SpecCommand context IO) r
forall (f :: * -> *) a. f (Free f a) -> Free f a
Free (SpecCommand context IO (Free (SpecCommand context IO) r)
x { nodeOptions = g (nodeOptions x)
                                              , next = alterTopLevelNodeOptions g (next x)})
alterTopLevelNodeOptions NodeOptions -> NodeOptions
_ x :: Free (SpecCommand context IO) r
x@(Pure r
_) = Free (SpecCommand context IO) r
x

systemVisibilityThreshold :: Int
systemVisibilityThreshold :: Int
systemVisibilityThreshold = Int
150