{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE MultiWayIf #-}
module Test.Sandwich.Formatters.TerminalUI.Filter (
filterRunTree
, treeToList
) where
import Control.Monad
import Control.Monad.Trans.Reader
import Data.Function
import qualified Data.List as L
import Test.Sandwich.Formatters.TerminalUI.Types
import Test.Sandwich.RunTree
import Test.Sandwich.Types.RunTree
filterRunTree :: Int -> [RunNodeFixed context] -> [RunNodeFixed context]
filterRunTree :: Int -> [RunNodeFixed context] -> [RunNodeFixed context]
filterRunTree Int
visibilityThreshold [RunNodeFixed context]
rtsFixed = [RunNodeFixed context]
rtsFixed
[RunNodeFixed context]
-> ([RunNodeFixed context] -> [RunNodeFixed context])
-> [RunNodeFixed context]
forall a b. a -> (a -> b) -> b
& (RunNodeFixed context -> RunNodeFixed context)
-> [RunNodeFixed context] -> [RunNodeFixed context]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((RunNodeCommonWithStatus Status (Seq LogEntry) Bool
-> RunNodeCommonWithStatus Status (Seq LogEntry) Bool)
-> RunNodeFixed context -> RunNodeFixed context
forall s l t context.
(RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t
mapCommon (Int
-> RunNodeCommonWithStatus Status (Seq LogEntry) Bool
-> RunNodeCommonWithStatus Status (Seq LogEntry) Bool
hideIfThresholdAbove Int
visibilityThreshold))
[RunNodeFixed context]
-> ([RunNodeFixed context] -> [RunNodeFixed context])
-> [RunNodeFixed context]
forall a b. a -> (a -> b) -> b
& (RunNodeFixed context -> RunNodeFixed context)
-> [RunNodeFixed context] -> [RunNodeFixed context]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RunNodeFixed context -> RunNodeFixed context
forall context s l.
RunNodeWithStatus context s l Bool
-> RunNodeWithStatus context s l Bool
hideClosed
mapCommon :: (RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t) -> RunNodeWithStatus context s l t -> RunNodeWithStatus context s l t
mapCommon :: (RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t
mapCommon RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f node :: RunNodeWithStatus context s l t
node@(RunNodeIt {}) = RunNodeWithStatus context s l t
node { runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeCommon = RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f (RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon RunNodeWithStatus context s l t
node) }
mapCommon RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f (RunNodeIntroduce {[RunNodeWithStatus (LabelValue lab intro :> context) s l t]
ExampleT context IO intro
RunNodeCommonWithStatus s l t
intro -> ExampleT context IO ()
runNodeCleanup :: ()
runNodeAlloc :: ()
runNodeChildrenAugmented :: ()
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeCommon :: forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..}) = RunNodeIntroduce :: 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 { runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeCommon = RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f RunNodeCommonWithStatus s l t
runNodeCommon
, runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeChildrenAugmented = (RunNodeWithStatus (LabelValue lab intro :> context) s l t
-> RunNodeWithStatus (LabelValue lab intro :> context) s l t)
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus (LabelValue lab intro :> context) s l t
-> RunNodeWithStatus (LabelValue lab intro :> context) s l t
forall s l t context.
(RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t
mapCommon RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f) [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeChildrenAugmented
, ExampleT context IO intro
intro -> ExampleT context IO ()
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
.. }
mapCommon RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f (RunNodeIntroduceWith {[RunNodeWithStatus (LabelValue lab intro :> context) s l t]
RunNodeCommonWithStatus s l t
(intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeIntroduceAction :: ()
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeChildrenAugmented :: ()
runNodeCommon :: forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..}) = RunNodeIntroduceWith :: 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 { runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeCommon = RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f RunNodeCommonWithStatus s l t
runNodeCommon
, runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeChildrenAugmented = (RunNodeWithStatus (LabelValue lab intro :> context) s l t
-> RunNodeWithStatus (LabelValue lab intro :> context) s l t)
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus (LabelValue lab intro :> context) s l t
-> RunNodeWithStatus (LabelValue lab intro :> context) s l t
forall s l t context.
(RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t
mapCommon RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f) [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeChildrenAugmented
, (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
.. }
mapCommon RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f RunNodeWithStatus context s l t
node = RunNodeWithStatus context s l t
node { runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeCommon = RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f (RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon RunNodeWithStatus context s l t
node)
, runNodeChildren :: [RunNodeWithStatus context s l t]
runNodeChildren = (RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t)
-> [RunNodeWithStatus context s l t]
-> [RunNodeWithStatus context s l t]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t
forall s l t context.
(RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t
mapCommon RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t
f) (RunNodeWithStatus context s l t
-> [RunNodeWithStatus context s l t]
forall context s l t.
RunNodeWithStatus context s l t
-> [RunNodeWithStatus context s l t]
runNodeChildren RunNodeWithStatus context s l t
node) }
hideIfThresholdAbove :: Int -> RunNodeCommonFixed -> RunNodeCommonFixed
hideIfThresholdAbove :: Int
-> RunNodeCommonWithStatus Status (Seq LogEntry) Bool
-> RunNodeCommonWithStatus Status (Seq LogEntry) Bool
hideIfThresholdAbove Int
visibilityThreshold node :: RunNodeCommonWithStatus Status (Seq LogEntry) Bool
node@(RunNodeCommonWithStatus {Bool
Int
String
Maybe String
Maybe SrcLoc
Seq Int
Seq LogEntry
Status
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 String
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 -> String
runTreeLoc :: Maybe SrcLoc
runTreeLogs :: Seq LogEntry
runTreeRecordTime :: Bool
runTreeVisibilityLevel :: Int
runTreeFolder :: Maybe String
runTreeVisible :: Bool
runTreeStatus :: Status
runTreeOpen :: Bool
runTreeToggled :: Bool
runTreeAncestors :: Seq Int
runTreeId :: Int
runTreeLabel :: String
..}) =
if | Int
runTreeVisibilityLevel Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
visibilityThreshold -> RunNodeCommonWithStatus Status (Seq LogEntry) Bool
node { runTreeVisible :: Bool
runTreeVisible = Bool
True }
| Bool
otherwise -> RunNodeCommonWithStatus Status (Seq LogEntry) Bool
node { runTreeVisible :: Bool
runTreeVisible = Bool
False
, runTreeOpen :: Bool
runTreeOpen = Bool
True
}
markClosed :: RunNodeCommonWithStatus s l Bool -> RunNodeCommonWithStatus s l Bool
markClosed :: RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool
markClosed node :: RunNodeCommonWithStatus s l Bool
node@(RunNodeCommonWithStatus {s
l
Bool
Int
String
Maybe String
Maybe SrcLoc
Seq Int
runTreeLoc :: Maybe SrcLoc
runTreeLogs :: l
runTreeRecordTime :: Bool
runTreeVisibilityLevel :: Int
runTreeFolder :: Maybe String
runTreeVisible :: Bool
runTreeStatus :: s
runTreeOpen :: Bool
runTreeToggled :: Bool
runTreeAncestors :: Seq Int
runTreeId :: Int
runTreeLabel :: String
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 String
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 -> String
..}) = RunNodeCommonWithStatus s l Bool
node { runTreeVisible :: Bool
runTreeVisible = Bool
False }
hideClosed :: RunNodeWithStatus context s l Bool -> RunNodeWithStatus context s l Bool
hideClosed :: RunNodeWithStatus context s l Bool
-> RunNodeWithStatus context s l Bool
hideClosed node :: RunNodeWithStatus context s l Bool
node@(RunNodeIt {}) = RunNodeWithStatus context s l Bool
node
hideClosed (RunNodeIntroduce {[RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
ExampleT context IO intro
RunNodeCommonWithStatus s l Bool
intro -> ExampleT context IO ()
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeCommon :: RunNodeCommonWithStatus s l Bool
runNodeCleanup :: ()
runNodeAlloc :: ()
runNodeChildrenAugmented :: ()
runNodeCommon :: forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..})
| RunNodeCommonWithStatus s l Bool -> Bool
forall s l t. RunNodeCommonWithStatus s l t -> t
runTreeOpen RunNodeCommonWithStatus s l Bool
runNodeCommon = RunNodeIntroduce :: 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 { runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeChildrenAugmented = (RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool)
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
forall context s l.
RunNodeWithStatus context s l Bool
-> RunNodeWithStatus context s l Bool
hideClosed [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeChildrenAugmented, ExampleT context IO intro
RunNodeCommonWithStatus s l Bool
intro -> ExampleT context IO ()
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
runNodeCommon :: RunNodeCommonWithStatus s l Bool
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
runNodeCommon :: RunNodeCommonWithStatus s l Bool
.. }
| Bool
otherwise = RunNodeIntroduce :: 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 { runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeChildrenAugmented = (RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool)
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool)
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
forall s l t context.
(RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t
mapCommon RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool
forall s l.
RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool
markClosed) [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeChildrenAugmented, ExampleT context IO intro
RunNodeCommonWithStatus s l Bool
intro -> ExampleT context IO ()
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
runNodeCommon :: RunNodeCommonWithStatus s l Bool
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
runNodeCommon :: RunNodeCommonWithStatus s l Bool
.. }
hideClosed (RunNodeIntroduceWith {[RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
RunNodeCommonWithStatus s l Bool
(intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeCommon :: RunNodeCommonWithStatus s l Bool
runNodeIntroduceAction :: ()
runNodeChildrenAugmented :: ()
runNodeCommon :: forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..})
| RunNodeCommonWithStatus s l Bool -> Bool
forall s l t. RunNodeCommonWithStatus s l t -> t
runTreeOpen RunNodeCommonWithStatus s l Bool
runNodeCommon = RunNodeIntroduceWith :: 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 { runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeChildrenAugmented = (RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool)
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
forall context s l.
RunNodeWithStatus context s l Bool
-> RunNodeWithStatus context s l Bool
hideClosed [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeChildrenAugmented, RunNodeCommonWithStatus s l Bool
(intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeCommon :: RunNodeCommonWithStatus s l Bool
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeCommon :: RunNodeCommonWithStatus s l Bool
.. }
| Bool
otherwise = RunNodeIntroduceWith :: 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 { runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeChildrenAugmented = (RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool)
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
-> [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool)
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
-> RunNodeWithStatus (LabelValue lab intro :> context) s l Bool
forall s l t context.
(RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t
mapCommon RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool
forall s l.
RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool
markClosed) [RunNodeWithStatus (LabelValue lab intro :> context) s l Bool]
runNodeChildrenAugmented, RunNodeCommonWithStatus s l Bool
(intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeCommon :: RunNodeCommonWithStatus s l Bool
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeCommon :: RunNodeCommonWithStatus s l Bool
.. }
hideClosed RunNodeWithStatus context s l Bool
node
| RunNodeCommonWithStatus s l Bool -> Bool
forall s l t. RunNodeCommonWithStatus s l t -> t
runTreeOpen (RunNodeWithStatus context s l Bool
-> RunNodeCommonWithStatus s l Bool
forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon RunNodeWithStatus context s l Bool
node) = RunNodeWithStatus context s l Bool
node { runNodeChildren :: [RunNodeWithStatus context s l Bool]
runNodeChildren = (RunNodeWithStatus context s l Bool
-> RunNodeWithStatus context s l Bool)
-> [RunNodeWithStatus context s l Bool]
-> [RunNodeWithStatus context s l Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RunNodeWithStatus context s l Bool
-> RunNodeWithStatus context s l Bool
forall context s l.
RunNodeWithStatus context s l Bool
-> RunNodeWithStatus context s l Bool
hideClosed (RunNodeWithStatus context s l Bool
-> [RunNodeWithStatus context s l Bool]
forall context s l t.
RunNodeWithStatus context s l t
-> [RunNodeWithStatus context s l t]
runNodeChildren RunNodeWithStatus context s l Bool
node) }
| Bool
otherwise = RunNodeWithStatus context s l Bool
node { runNodeChildren :: [RunNodeWithStatus context s l Bool]
runNodeChildren = (RunNodeWithStatus context s l Bool
-> RunNodeWithStatus context s l Bool)
-> [RunNodeWithStatus context s l Bool]
-> [RunNodeWithStatus context s l Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool)
-> RunNodeWithStatus context s l Bool
-> RunNodeWithStatus context s l Bool
forall s l t context.
(RunNodeCommonWithStatus s l t -> RunNodeCommonWithStatus s l t)
-> RunNodeWithStatus context s l t
-> RunNodeWithStatus context s l t
mapCommon RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool
forall s l.
RunNodeCommonWithStatus s l Bool
-> RunNodeCommonWithStatus s l Bool
markClosed) (RunNodeWithStatus context s l Bool
-> [RunNodeWithStatus context s l Bool]
forall context s l t.
RunNodeWithStatus context s l t
-> [RunNodeWithStatus context s l t]
runNodeChildren RunNodeWithStatus context s l Bool
node) }
treeToList :: (RunNodeFixed context, RunNode context) -> [MainListElem]
treeToList :: (RunNodeFixed context, RunNode context) -> [MainListElem]
treeToList (RunNodeFixed context
nodeFixed, RunNode context
node) = [(RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int)]
-> [RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool)]
-> [((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))]
forall a b. [a] -> [b] -> [(a, b)]
L.zip (Reader
Int [(RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int)]
-> Int
-> [(RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int)]
forall r a. Reader r a -> r -> a
runReader (RunNodeFixed context
-> Reader
Int [(RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int)]
forall context s l t.
RunNodeWithStatus context s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
getCommonsWithVisibleDepth' RunNodeFixed context
nodeFixed) Int
0) (RunNode context
-> [RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool)]
forall context s l t.
RunNodeWithStatus context s l t -> [RunNodeCommonWithStatus s l t]
getCommons RunNode context
node)
[((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))]
-> ([((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))]
-> [((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))])
-> [((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))]
forall a b. a -> (a -> b) -> b
& (((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))
-> Bool)
-> [((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))]
-> [((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))]
forall a. (a -> Bool) -> [a] -> [a]
L.filter (RunNodeCommonWithStatus Status (Seq LogEntry) Bool -> Bool
isVisible (RunNodeCommonWithStatus Status (Seq LogEntry) Bool -> Bool)
-> (((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))
-> RunNodeCommonWithStatus Status (Seq LogEntry) Bool)
-> ((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int)
-> RunNodeCommonWithStatus Status (Seq LogEntry) Bool
forall a b. (a, b) -> a
fst ((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int)
-> RunNodeCommonWithStatus Status (Seq LogEntry) Bool)
-> (((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))
-> (RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int))
-> ((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))
-> RunNodeCommonWithStatus Status (Seq LogEntry) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))
-> (RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int)
forall a b. (a, b) -> a
fst)
[((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))]
-> ([((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))]
-> [MainListElem])
-> [MainListElem]
forall a b. a -> (a -> b) -> b
& (((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))
-> MainListElem)
-> [((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))]
-> [MainListElem]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))
-> MainListElem
commonToMainListElem
where
isVisible :: RunNodeCommonFixed -> Bool
isVisible :: RunNodeCommonWithStatus Status (Seq LogEntry) Bool -> Bool
isVisible (RunNodeCommonWithStatus {Bool
Int
String
Maybe String
Maybe SrcLoc
Seq Int
Seq LogEntry
Status
runTreeLoc :: Maybe SrcLoc
runTreeLogs :: Seq LogEntry
runTreeRecordTime :: Bool
runTreeVisibilityLevel :: Int
runTreeFolder :: Maybe String
runTreeVisible :: Bool
runTreeStatus :: Status
runTreeOpen :: Bool
runTreeToggled :: Bool
runTreeAncestors :: Seq Int
runTreeId :: Int
runTreeLabel :: String
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 String
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 -> String
..}) = Bool
runTreeVisible
commonToMainListElem :: ((RunNodeCommonFixed, Int), RunNodeCommon) -> MainListElem
commonToMainListElem :: ((RunNodeCommonWithStatus Status (Seq LogEntry) Bool, Int),
RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool))
-> MainListElem
commonToMainListElem ((RunNodeCommonWithStatus {Bool
Int
String
Maybe String
Maybe SrcLoc
Seq Int
Seq LogEntry
Status
runTreeLoc :: Maybe SrcLoc
runTreeLogs :: Seq LogEntry
runTreeRecordTime :: Bool
runTreeVisibilityLevel :: Int
runTreeFolder :: Maybe String
runTreeVisible :: Bool
runTreeStatus :: Status
runTreeOpen :: Bool
runTreeToggled :: Bool
runTreeAncestors :: Seq Int
runTreeId :: Int
runTreeLabel :: String
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 String
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 -> String
..}, Int
depth), RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool)
common) = MainListElem :: String
-> Int
-> Bool
-> Bool
-> Status
-> Seq LogEntry
-> Int
-> Maybe String
-> RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool)
-> Int
-> MainListElem
MainListElem {
label :: String
label = String
runTreeLabel
, depth :: Int
depth = Int
depth
, toggled :: Bool
toggled = Bool
runTreeToggled
, open :: Bool
open = Bool
runTreeOpen
, status :: Status
status = Status
runTreeStatus
, logs :: Seq LogEntry
logs = Seq LogEntry
runTreeLogs
, visibilityLevel :: Int
visibilityLevel = Int
runTreeVisibilityLevel
, folderPath :: Maybe String
folderPath = Maybe String
runTreeFolder
, node :: RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool)
node = RunNodeCommonWithStatus
(Var Status) (Var (Seq LogEntry)) (Var Bool)
common
, ident :: Int
ident = Int
runTreeId
}
getCommonsWithVisibleDepth' :: RunNodeWithStatus context s l t -> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
getCommonsWithVisibleDepth' :: RunNodeWithStatus context s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
getCommonsWithVisibleDepth' node :: RunNodeWithStatus context s l t
node@(RunNodeIt {}) = ReaderT Int Identity Int
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask ReaderT Int Identity Int
-> (Int -> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
vd -> [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a. Monad m => a -> m a
return [(RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon RunNodeWithStatus context s l t
node, Int
vd)]
getCommonsWithVisibleDepth' (RunNodeIntroduce {[RunNodeWithStatus (LabelValue lab intro :> context) s l t]
ExampleT context IO intro
RunNodeCommonWithStatus s l t
intro -> ExampleT context IO ()
runNodeCleanup :: intro -> ExampleT context IO ()
runNodeAlloc :: ExampleT context IO intro
runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeCleanup :: ()
runNodeAlloc :: ()
runNodeChildrenAugmented :: ()
runNodeCommon :: forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..}) = do
let context :: ReaderT Int m a -> ReaderT Int m a
context = if RunNodeCommonWithStatus s l t -> Bool
forall s l t. RunNodeCommonWithStatus s l t -> Bool
runTreeVisible RunNodeCommonWithStatus s l t
runNodeCommon then ((Int -> Int) -> ReaderT Int m a -> ReaderT Int m a
forall r (m :: * -> *) a.
(r -> r) -> ReaderT r m a -> ReaderT r m a
local (Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)) else ReaderT Int m a -> ReaderT Int m a
forall a. a -> a
id
[(RunNodeCommonWithStatus s l t, Int)]
rest <- Reader Int [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a. ReaderT Int m a -> ReaderT Int m a
context (Reader Int [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall a b. (a -> b) -> a -> b
$ ([[(RunNodeCommonWithStatus s l t, Int)]]
-> [(RunNodeCommonWithStatus s l t, Int)]
forall a. Monoid a => [a] -> a
mconcat ([[(RunNodeCommonWithStatus s l t, Int)]]
-> [(RunNodeCommonWithStatus s l t, Int)])
-> ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall a b. (a -> b) -> a -> b
$ [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
-> (RunNodeWithStatus (LabelValue lab intro :> context) s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeChildrenAugmented RunNodeWithStatus (LabelValue lab intro :> context) s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall context s l t.
RunNodeWithStatus context s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
getCommonsWithVisibleDepth'
ReaderT Int Identity Int
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask ReaderT Int Identity Int
-> (Int -> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
vd -> [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a. Monad m => a -> m a
return ((RunNodeCommonWithStatus s l t
runNodeCommon, Int
vd) (RunNodeCommonWithStatus s l t, Int)
-> [(RunNodeCommonWithStatus s l t, Int)]
-> [(RunNodeCommonWithStatus s l t, Int)]
forall a. a -> [a] -> [a]
: [(RunNodeCommonWithStatus s l t, Int)]
rest)
getCommonsWithVisibleDepth' (RunNodeIntroduceWith {[RunNodeWithStatus (LabelValue lab intro :> context) s l t]
RunNodeCommonWithStatus s l t
(intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeIntroduceAction :: (intro -> ExampleT context IO [Result]) -> ExampleT context IO ()
runNodeChildrenAugmented :: [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeCommon :: RunNodeCommonWithStatus s l t
runNodeIntroduceAction :: ()
runNodeChildrenAugmented :: ()
runNodeCommon :: forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
..}) = do
let context :: ReaderT Int m a -> ReaderT Int m a
context = if RunNodeCommonWithStatus s l t -> Bool
forall s l t. RunNodeCommonWithStatus s l t -> Bool
runTreeVisible RunNodeCommonWithStatus s l t
runNodeCommon then ((Int -> Int) -> ReaderT Int m a -> ReaderT Int m a
forall r (m :: * -> *) a.
(r -> r) -> ReaderT r m a -> ReaderT r m a
local (Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)) else ReaderT Int m a -> ReaderT Int m a
forall a. a -> a
id
[(RunNodeCommonWithStatus s l t, Int)]
rest <- Reader Int [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a. ReaderT Int m a -> ReaderT Int m a
context (Reader Int [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall a b. (a -> b) -> a -> b
$ ([[(RunNodeCommonWithStatus s l t, Int)]]
-> [(RunNodeCommonWithStatus s l t, Int)]
forall a. Monoid a => [a] -> a
mconcat ([[(RunNodeCommonWithStatus s l t, Int)]]
-> [(RunNodeCommonWithStatus s l t, Int)])
-> ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall a b. (a -> b) -> a -> b
$ [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
-> (RunNodeWithStatus (LabelValue lab intro :> context) s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [RunNodeWithStatus (LabelValue lab intro :> context) s l t]
runNodeChildrenAugmented RunNodeWithStatus (LabelValue lab intro :> context) s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall context s l t.
RunNodeWithStatus context s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
getCommonsWithVisibleDepth'
ReaderT Int Identity Int
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask ReaderT Int Identity Int
-> (Int -> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
vd -> [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a. Monad m => a -> m a
return ((RunNodeCommonWithStatus s l t
runNodeCommon, Int
vd) (RunNodeCommonWithStatus s l t, Int)
-> [(RunNodeCommonWithStatus s l t, Int)]
-> [(RunNodeCommonWithStatus s l t, Int)]
forall a. a -> [a] -> [a]
: [(RunNodeCommonWithStatus s l t, Int)]
rest)
getCommonsWithVisibleDepth' RunNodeWithStatus context s l t
node = do
let context :: ReaderT Int m a -> ReaderT Int m a
context = if RunNodeCommonWithStatus s l t -> Bool
forall s l t. RunNodeCommonWithStatus s l t -> Bool
runTreeVisible (RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon RunNodeWithStatus context s l t
node) then ((Int -> Int) -> ReaderT Int m a -> ReaderT Int m a
forall r (m :: * -> *) a.
(r -> r) -> ReaderT r m a -> ReaderT r m a
local (Int -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)) else ReaderT Int m a -> ReaderT Int m a
forall a. a -> a
id
[(RunNodeCommonWithStatus s l t, Int)]
rest <- Reader Int [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a. ReaderT Int m a -> ReaderT Int m a
context (Reader Int [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall a b. (a -> b) -> a -> b
$ ([[(RunNodeCommonWithStatus s l t, Int)]]
-> [(RunNodeCommonWithStatus s l t, Int)]
forall a. Monoid a => [a] -> a
mconcat ([[(RunNodeCommonWithStatus s l t, Int)]]
-> [(RunNodeCommonWithStatus s l t, Int)])
-> ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall a b. (a -> b) -> a -> b
$ [RunNodeWithStatus context s l t]
-> (RunNodeWithStatus context s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> ReaderT Int Identity [[(RunNodeCommonWithStatus s l t, Int)]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM (RunNodeWithStatus context s l t
-> [RunNodeWithStatus context s l t]
forall context s l t.
RunNodeWithStatus context s l t
-> [RunNodeWithStatus context s l t]
runNodeChildren RunNodeWithStatus context s l t
node) RunNodeWithStatus context s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall context s l t.
RunNodeWithStatus context s l t
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
getCommonsWithVisibleDepth'
ReaderT Int Identity Int
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask ReaderT Int Identity Int
-> (Int -> Reader Int [(RunNodeCommonWithStatus s l t, Int)])
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
vd -> [(RunNodeCommonWithStatus s l t, Int)]
-> Reader Int [(RunNodeCommonWithStatus s l t, Int)]
forall (m :: * -> *) a. Monad m => a -> m a
return ((RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
forall context s l t.
RunNodeWithStatus context s l t -> RunNodeCommonWithStatus s l t
runNodeCommon RunNodeWithStatus context s l t
node, Int
vd) (RunNodeCommonWithStatus s l t, Int)
-> [(RunNodeCommonWithStatus s l t, Int)]
-> [(RunNodeCommonWithStatus s l t, Int)]
forall a. a -> [a] -> [a]
: [(RunNodeCommonWithStatus s l t, Int)]
rest)