{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE MultiWayIf #-}

module Test.Sandwich.Interpreters.RunTree (
  specToRunTree
  , specToRunTreeVariable
  , isEmptySpec
  ) where

import Control.Concurrent.STM
import Control.Monad.Free
import Control.Monad.Trans.RWS
import Data.Functor.Identity
import qualified Data.List as L
import Data.Sequence
import GHC.Stack
import System.FilePath
import Test.Sandwich.Interpreters.RunTree.Util
import Test.Sandwich.RunTree
import Test.Sandwich.Types.RunTree
import Test.Sandwich.Types.Spec


specToRunTree :: BaseContext -> Free (SpecCommand BaseContext IO) () -> [RunNodeFixed BaseContext]
specToRunTree :: BaseContext
-> Free (SpecCommand BaseContext IO) ()
-> [RunNodeFixed BaseContext]
specToRunTree BaseContext
baseContext Free (SpecCommand BaseContext IO) ()
spec = forall a. Identity a -> a
runIdentity forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *).
Monad m =>
BaseContext
-> Free (SpecCommand BaseContext IO) ()
-> m [RunNodeFixed BaseContext]
specToRunTreeM BaseContext
baseContext Free (SpecCommand BaseContext IO) ()
spec

specToRunTreeVariable :: BaseContext -> Free (SpecCommand BaseContext IO) () -> STM [RunNode BaseContext]
specToRunTreeVariable :: BaseContext
-> Free (SpecCommand BaseContext IO) ()
-> STM [RunNode BaseContext]
specToRunTreeVariable BaseContext
bc Free (SpecCommand BaseContext IO) ()
spec = forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM forall context. RunNodeFixed context -> STM (RunNode context)
unFixRunTree forall a b. (a -> b) -> a -> b
$ BaseContext
-> Free (SpecCommand BaseContext IO) ()
-> [RunNodeFixed BaseContext]
specToRunTree BaseContext
bc Free (SpecCommand BaseContext IO) ()
spec

isEmptySpec :: forall context. Free (SpecCommand context IO) () -> Bool
isEmptySpec :: forall context. Free (SpecCommand context IO) () -> Bool
isEmptySpec Free (SpecCommand context IO) ()
spec = forall (t :: * -> *) a. Foldable t => t a -> Bool
L.null [RunNodeFixed context]
ret
  where context :: RunTreeContext
context = RunTreeContext {
          runTreeIndexInParent :: Int
runTreeIndexInParent = Int
0
          , runTreeNumSiblings :: Int
runTreeNumSiblings = Int
0
          , runTreeCurrentAncestors :: Seq Int
runTreeCurrentAncestors = forall a. Monoid a => a
mempty
          , runTreeCurrentFolder :: Maybe FilePath
runTreeCurrentFolder = forall a. Maybe a
Nothing
          }
        ([RunNodeFixed context]
ret, Int
_, ()
_) = forall a. Identity a -> a
runIdentity forall a b. (a -> b) -> a -> b
$ forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
runRWST (forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
specToRunTree' Free (SpecCommand context IO) ()
spec) RunTreeContext
context Int
0

specToRunTreeM :: (Monad m) => BaseContext -> Free (SpecCommand BaseContext IO) () -> m [RunNodeFixed BaseContext]
specToRunTreeM :: forall (m :: * -> *).
Monad m =>
BaseContext
-> Free (SpecCommand BaseContext IO) ()
-> m [RunNodeFixed BaseContext]
specToRunTreeM BaseContext
baseContext Free (SpecCommand BaseContext IO) ()
spec = do
  let context :: RunTreeContext
context = RunTreeContext {
        runTreeIndexInParent :: Int
runTreeIndexInParent = Int
0
        , runTreeNumSiblings :: Int
runTreeNumSiblings = forall context (m :: * -> *).
Free (SpecCommand context m) () -> Int
countChildren Free (SpecCommand BaseContext IO) ()
spec
        , runTreeCurrentAncestors :: Seq Int
runTreeCurrentAncestors = forall a. Monoid a => a
mempty
        , runTreeCurrentFolder :: Maybe FilePath
runTreeCurrentFolder = (FilePath -> FilePath -> FilePath
</> FilePath
"results") forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> BaseContext -> Maybe FilePath
baseContextRunRoot BaseContext
baseContext
        }
  ([RunNodeFixed BaseContext]
ret, Int
_, ()
_) <- forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
runRWST (forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
specToRunTree' Free (SpecCommand BaseContext IO) ()
spec) RunTreeContext
context Int
0
  forall (m :: * -> *) a. Monad m => a -> m a
return [RunNodeFixed BaseContext]
ret

-- | Convert a spec to a run tree
specToRunTree' :: (Monad m) => Free (SpecCommand context IO) r -> ConvertM m [RunNodeFixed context]
specToRunTree' :: forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
specToRunTree' (Free (Before'' Maybe SrcLoc
loc NodeOptions
no FilePath
l ExampleT context IO ()
f SpecFree context IO ()
subspec Free (SpecCommand context IO) r
next)) = do
  RunNodeCommonFixed
common <- forall (m :: * -> *).
Monad m =>
FilePath
-> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon FilePath
l Maybe SrcLoc
loc NodeOptions
no
  forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith Free (SpecCommand context IO) r
next forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s l t context.
RunNodeCommonWithStatus s l t
-> [RunNodeWithStatus context s l t]
-> ExampleT context IO ()
-> RunNodeWithStatus context s l t
RunNodeBefore RunNodeCommonFixed
common forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) context r.
Monad m =>
FilePath
-> NodeOptions
-> RunNodeCommonFixed
-> Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
recurse FilePath
l NodeOptions
no RunNodeCommonFixed
common SpecFree context IO ()
subspec forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure ExampleT context IO ()
f
specToRunTree' (Free (After'' Maybe SrcLoc
loc NodeOptions
no FilePath
l ExampleT context IO ()
f SpecFree context IO ()
subspec Free (SpecCommand context IO) r
next)) = do
  RunNodeCommonFixed
common <- forall (m :: * -> *).
Monad m =>
FilePath
-> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon FilePath
l Maybe SrcLoc
loc NodeOptions
no
  forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith Free (SpecCommand context IO) r
next forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s l t context.
RunNodeCommonWithStatus s l t
-> [RunNodeWithStatus context s l t]
-> ExampleT context IO ()
-> RunNodeWithStatus context s l t
RunNodeAfter RunNodeCommonFixed
common forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) context r.
Monad m =>
FilePath
-> NodeOptions
-> RunNodeCommonFixed
-> Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
recurse FilePath
l NodeOptions
no RunNodeCommonFixed
common SpecFree context IO ()
subspec forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure ExampleT context IO ()
f
specToRunTree' (Free (Introduce'' Maybe SrcLoc
loc NodeOptions
no FilePath
l Label l intro
_cl ExampleT context IO intro
alloc intro -> ExampleT context IO ()
cleanup SpecFree (LabelValue l intro :> context) IO ()
subspec Free (SpecCommand context IO) r
next)) = do
  RunNodeCommonFixed
common <- forall (m :: * -> *).
Monad m =>
FilePath
-> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon FilePath
l Maybe SrcLoc
loc NodeOptions
no
  forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith Free (SpecCommand context IO) r
next forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall intro s l t (lab :: Symbol) context.
Typeable intro =>
RunNodeCommonWithStatus s l t
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
-> ExampleT context IO intro
-> (intro -> ExampleT context IO ())
-> RunNodeWithStatus context s l t
RunNodeIntroduce RunNodeCommonFixed
common forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) context r.
Monad m =>
FilePath
-> NodeOptions
-> RunNodeCommonFixed
-> Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
recurse FilePath
l NodeOptions
no RunNodeCommonFixed
common SpecFree (LabelValue l intro :> context) IO ()
subspec forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure ExampleT context IO intro
alloc forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure intro -> ExampleT context IO ()
cleanup
specToRunTree' (Free (IntroduceWith'' Maybe SrcLoc
loc NodeOptions
no FilePath
l Label l intro
_cl (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
action SpecFree (LabelValue l intro :> context) IO ()
subspec Free (SpecCommand context IO) r
next)) = do
  RunNodeCommonFixed
common <- forall (m :: * -> *).
Monad m =>
FilePath
-> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon FilePath
l Maybe SrcLoc
loc NodeOptions
no
  forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith Free (SpecCommand context IO) r
next forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s l t (lab :: Symbol) intro context.
RunNodeCommonWithStatus s l t
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
-> ((intro -> ExampleT context IO [Result])
    -> ExampleT context IO ())
-> RunNodeWithStatus context s l t
RunNodeIntroduceWith RunNodeCommonFixed
common forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) context r.
Monad m =>
FilePath
-> NodeOptions
-> RunNodeCommonFixed
-> Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
recurse FilePath
l NodeOptions
no RunNodeCommonFixed
common SpecFree (LabelValue l intro :> context) IO ()
subspec forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
action
specToRunTree' (Free (Around'' Maybe SrcLoc
loc NodeOptions
no FilePath
l ExampleT context IO [Result] -> ExampleT context IO ()
actionWith SpecFree context IO ()
subspec Free (SpecCommand context IO) r
next)) = do
  RunNodeCommonFixed
common <- forall (m :: * -> *).
Monad m =>
FilePath
-> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon FilePath
l Maybe SrcLoc
loc NodeOptions
no
  forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith Free (SpecCommand context IO) r
next forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s l t context.
RunNodeCommonWithStatus s l t
-> [RunNodeWithStatus context s l t]
-> (ExampleT context IO [Result] -> ExampleT context IO ())
-> RunNodeWithStatus context s l t
RunNodeAround RunNodeCommonFixed
common forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) context r.
Monad m =>
FilePath
-> NodeOptions
-> RunNodeCommonFixed
-> Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
recurse FilePath
l NodeOptions
no RunNodeCommonFixed
common SpecFree context IO ()
subspec forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure ExampleT context IO [Result] -> ExampleT context IO ()
actionWith
specToRunTree' (Free (Describe'' Maybe SrcLoc
loc NodeOptions
no FilePath
l SpecFree context IO ()
subspec Free (SpecCommand context IO) r
next)) = do
  RunNodeCommonFixed
common <- forall (m :: * -> *).
Monad m =>
FilePath
-> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon FilePath
l Maybe SrcLoc
loc NodeOptions
no
  forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith Free (SpecCommand context IO) r
next forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s l t context.
RunNodeCommonWithStatus s l t
-> [RunNodeWithStatus context s l t]
-> RunNodeWithStatus context s l t
RunNodeDescribe RunNodeCommonFixed
common forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) context r.
Monad m =>
FilePath
-> NodeOptions
-> RunNodeCommonFixed
-> Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
recurse FilePath
l NodeOptions
no RunNodeCommonFixed
common SpecFree context IO ()
subspec
specToRunTree' (Free (Parallel'' Maybe SrcLoc
loc NodeOptions
no SpecFree context IO ()
subspec Free (SpecCommand context IO) r
next)) = do
  RunNodeCommonFixed
common <- forall (m :: * -> *).
Monad m =>
FilePath
-> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon FilePath
"Parallel" Maybe SrcLoc
loc NodeOptions
no
  forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith Free (SpecCommand context IO) r
next forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s l t context.
RunNodeCommonWithStatus s l t
-> [RunNodeWithStatus context s l t]
-> RunNodeWithStatus context s l t
RunNodeParallel RunNodeCommonFixed
common forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) context r.
Monad m =>
FilePath
-> NodeOptions
-> RunNodeCommonFixed
-> Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
recurse FilePath
"Parallel" NodeOptions
no RunNodeCommonFixed
common SpecFree context IO ()
subspec
specToRunTree' (Free (It'' Maybe SrcLoc
loc NodeOptions
no FilePath
l ExampleT context IO ()
example Free (SpecCommand context IO) r
next)) = do
  RunNodeCommonFixed
common <- forall (m :: * -> *).
Monad m =>
FilePath
-> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon FilePath
l Maybe SrcLoc
loc NodeOptions
no
  forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith Free (SpecCommand context IO) r
next forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s l t context.
RunNodeCommonWithStatus s l t
-> ExampleT context IO () -> RunNodeWithStatus context s l t
RunNodeIt RunNodeCommonFixed
common forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a. Applicative f => a -> f a
pure ExampleT context IO ()
example
specToRunTree' (Pure r
_) = forall (m :: * -> *) a. Monad m => a -> m a
return []


-- * Util

type ConvertM m = RWST RunTreeContext () Int m

getCommon :: (Monad m) => String -> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon :: forall (m :: * -> *).
Monad m =>
FilePath
-> Maybe SrcLoc -> NodeOptions -> ConvertM m RunNodeCommonFixed
getCommon FilePath
l Maybe SrcLoc
srcLoc (NodeOptions {Bool
Int
Maybe NodeModuleInfo
nodeOptionsModuleInfo :: NodeOptions -> Maybe NodeModuleInfo
nodeOptionsRecordTime :: NodeOptions -> Bool
nodeOptionsCreateFolder :: NodeOptions -> Bool
nodeOptionsVisibilityThreshold :: NodeOptions -> Int
nodeOptionsModuleInfo :: Maybe NodeModuleInfo
nodeOptionsRecordTime :: Bool
nodeOptionsCreateFolder :: Bool
nodeOptionsVisibilityThreshold :: Int
..}) = do
  RunTreeContext {Int
Maybe FilePath
Seq Int
runTreeNumSiblings :: Int
runTreeIndexInParent :: Int
runTreeCurrentAncestors :: Seq Int
runTreeCurrentFolder :: Maybe FilePath
runTreeCurrentFolder :: RunTreeContext -> Maybe FilePath
runTreeCurrentAncestors :: RunTreeContext -> Seq Int
runTreeNumSiblings :: RunTreeContext -> Int
runTreeIndexInParent :: RunTreeContext -> Int
..} <- forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m r
ask

  -- Get a unique ID for this node
  Int
ident <- forall w (m :: * -> *) r s. (Monoid w, Monad m) => RWST r w s m s
get
  forall w (m :: * -> *) s r.
(Monoid w, Monad m) =>
(s -> s) -> RWST r w s m ()
modify (forall a. Num a => a -> a -> a
+Int
1)

  forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ RunNodeCommonWithStatus {
    runTreeLabel :: FilePath
runTreeLabel = FilePath
l
    , runTreeId :: Int
runTreeId = Int
ident
    , runTreeAncestors :: Seq Int
runTreeAncestors = Seq Int
runTreeCurrentAncestors forall a. Seq a -> a -> Seq a
|> Int
ident
    , runTreeToggled :: Bool
runTreeToggled = Bool
False
    , runTreeOpen :: Bool
runTreeOpen = Bool
True
    , runTreeStatus :: Status
runTreeStatus = Status
NotStarted
    , runTreeVisible :: Bool
runTreeVisible = Bool
True
    , runTreeFolder :: Maybe FilePath
runTreeFolder = case (Bool
nodeOptionsCreateFolder, Maybe FilePath
runTreeCurrentFolder) of
        (Bool
True, Just FilePath
f) -> forall a. a -> Maybe a
Just (FilePath
f FilePath -> FilePath -> FilePath
</> (FilePath -> Int -> Int -> FilePath
nodeToFolderName FilePath
l Int
runTreeNumSiblings Int
runTreeIndexInParent))
        (Bool, Maybe FilePath)
_ -> forall a. Maybe a
Nothing
    , runTreeVisibilityLevel :: Int
runTreeVisibilityLevel = Int
nodeOptionsVisibilityThreshold
    , runTreeRecordTime :: Bool
runTreeRecordTime = Bool
nodeOptionsRecordTime
    , runTreeLogs :: Seq LogEntry
runTreeLogs = forall a. Monoid a => a
mempty
    , runTreeLoc :: Maybe SrcLoc
runTreeLoc = Maybe SrcLoc
srcLoc
    }

continueWith :: (Monad m) => Free (SpecCommand context IO) r -> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith :: forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> RunNodeFixed context -> ConvertM m [RunNodeFixed context]
continueWith Free (SpecCommand context IO) r
next RunNodeFixed context
node = do
  [RunNodeFixed context]
rest <- forall r w s (m :: * -> *) a.
(r -> r) -> RWST r w s m a -> RWST r w s m a
local (\RunTreeContext
rtc -> RunTreeContext
rtc { runTreeIndexInParent :: Int
runTreeIndexInParent = (RunTreeContext -> Int
runTreeIndexInParent RunTreeContext
rtc) forall a. Num a => a -> a -> a
+ Int
1 }) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
specToRunTree' Free (SpecCommand context IO) r
next
  forall (m :: * -> *) a. Monad m => a -> m a
return (RunNodeFixed context
node forall a. a -> [a] -> [a]
: [RunNodeFixed context]
rest)

recurse :: (Monad m) => String -> NodeOptions -> RunNodeCommonFixed -> Free (SpecCommand context IO) r -> ConvertM m [RunNodeFixed context]
recurse :: forall (m :: * -> *) context r.
Monad m =>
FilePath
-> NodeOptions
-> RunNodeCommonFixed
-> Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
recurse FilePath
l (NodeOptions {Bool
Int
Maybe NodeModuleInfo
nodeOptionsModuleInfo :: Maybe NodeModuleInfo
nodeOptionsRecordTime :: Bool
nodeOptionsCreateFolder :: Bool
nodeOptionsVisibilityThreshold :: Int
nodeOptionsModuleInfo :: NodeOptions -> Maybe NodeModuleInfo
nodeOptionsRecordTime :: NodeOptions -> Bool
nodeOptionsCreateFolder :: NodeOptions -> Bool
nodeOptionsVisibilityThreshold :: NodeOptions -> Int
..}) (RunNodeCommonWithStatus {Bool
Int
FilePath
Maybe FilePath
Maybe SrcLoc
Seq Int
Seq LogEntry
Status
runTreeLoc :: Maybe SrcLoc
runTreeLogs :: Seq LogEntry
runTreeRecordTime :: Bool
runTreeVisibilityLevel :: Int
runTreeFolder :: Maybe FilePath
runTreeVisible :: Bool
runTreeStatus :: Status
runTreeOpen :: Bool
runTreeToggled :: Bool
runTreeAncestors :: Seq Int
runTreeId :: Int
runTreeLabel :: FilePath
runTreeLoc :: forall s l t. RunNodeCommonWithStatus s l t -> Maybe SrcLoc
runTreeLogs :: forall s l t. RunNodeCommonWithStatus s l t -> l
runTreeRecordTime :: forall s l t. RunNodeCommonWithStatus s l t -> Bool
runTreeVisibilityLevel :: forall s l t. RunNodeCommonWithStatus s l t -> Int
runTreeFolder :: forall s l t. RunNodeCommonWithStatus s l t -> Maybe FilePath
runTreeVisible :: forall s l t. RunNodeCommonWithStatus s l t -> Bool
runTreeStatus :: forall s l t. RunNodeCommonWithStatus s l t -> s
runTreeOpen :: forall s l t. RunNodeCommonWithStatus s l t -> t
runTreeToggled :: forall s l t. RunNodeCommonWithStatus s l t -> t
runTreeAncestors :: forall s l t. RunNodeCommonWithStatus s l t -> Seq Int
runTreeId :: forall s l t. RunNodeCommonWithStatus s l t -> Int
runTreeLabel :: forall s l t. RunNodeCommonWithStatus s l t -> FilePath
..}) Free (SpecCommand context IO) r
subspec = forall r w s (m :: * -> *) a.
(r -> r) -> RWST r w s m a -> RWST r w s m a
local
  (\RunTreeContext
rtc ->
     if | Bool
nodeOptionsCreateFolder ->
          RunTreeContext
rtc { runTreeCurrentFolder :: Maybe FilePath
runTreeCurrentFolder = case RunTreeContext -> Maybe FilePath
runTreeCurrentFolder RunTreeContext
rtc of
                  Maybe FilePath
Nothing -> forall a. Maybe a
Nothing
                  Just FilePath
f -> forall a. a -> Maybe a
Just (FilePath
f FilePath -> FilePath -> FilePath
</> (FilePath -> Int -> Int -> FilePath
nodeToFolderName FilePath
l (RunTreeContext -> Int
runTreeNumSiblings RunTreeContext
rtc) (RunTreeContext -> Int
runTreeIndexInParent RunTreeContext
rtc)))
              , runTreeIndexInParent :: Int
runTreeIndexInParent = Int
0
              , runTreeNumSiblings :: Int
runTreeNumSiblings = forall context (m :: * -> *) a.
Free (SpecCommand context m) a -> Int
countImmediateFolderChildren Free (SpecCommand context IO) r
subspec
              , runTreeCurrentAncestors :: Seq Int
runTreeCurrentAncestors = Seq Int
runTreeAncestors
              }
        | Bool
otherwise ->
          RunTreeContext
rtc { runTreeCurrentAncestors :: Seq Int
runTreeCurrentAncestors = Seq Int
runTreeAncestors }
  )
  (forall (m :: * -> *) context r.
Monad m =>
Free (SpecCommand context IO) r
-> ConvertM m [RunNodeFixed context]
specToRunTree' Free (SpecCommand context IO) r
subspec)