Refactor tell use slighly
This commit is contained in:
parent
4884136dad
commit
de6495d750
|
@ -44,6 +44,9 @@ evalComputationM' top m = runState (execWriterT (unComputationM m)) top
|
||||||
evalComputationM :: ComputationM () -> [DependencyUntyped]
|
evalComputationM :: ComputationM () -> [DependencyUntyped]
|
||||||
evalComputationM m = fst (evalComputationM' 0 m)
|
evalComputationM m = fst (evalComputationM' 0 m)
|
||||||
|
|
||||||
|
tellDep :: (Show a, Show b) => Dependency a b -> ComputationM' ()
|
||||||
|
tellDep dep = tell [DependencyUntyped dep (show dep)] -- Call show for later debugging purposes
|
||||||
|
|
||||||
genDependency' :: (Show u, Show a) => (Token a -> ComputationM' (Dependency u a)) -> ComputationM a
|
genDependency' :: (Show u, Show a) => (Token a -> ComputationM' (Dependency u a)) -> ComputationM a
|
||||||
genDependency' f = do
|
genDependency' f = do
|
||||||
top <- get
|
top <- get
|
||||||
|
@ -51,11 +54,11 @@ genDependency' f = do
|
||||||
target = Token top'
|
target = Token top'
|
||||||
put top'
|
put top'
|
||||||
result <- f target
|
result <- f target
|
||||||
tell [DependencyUntyped result (show result)]
|
tellDep result
|
||||||
pure target
|
pure target
|
||||||
|
|
||||||
genDependency :: (Show u, Show a) => (Token a -> Dependency u a) -> ComputationM a
|
genDependency :: (Show u, Show a) => (Token a -> Dependency u a) -> ComputationM a
|
||||||
genDependency g = genDependency' (\t -> pure $ g t)
|
genDependency f = genDependency' (pure . f)
|
||||||
|
|
||||||
inject :: Show a => a -> ComputationM a
|
inject :: Show a => a -> ComputationM a
|
||||||
inject x = genDependency (Dependency NoToken (Inject x))
|
inject x = genDependency (Dependency NoToken (Inject x))
|
||||||
|
@ -65,9 +68,8 @@ getListElem outer = genDependency (Dependency outer GetListElem)
|
||||||
|
|
||||||
setListElem :: Show a => Token a -> Token [a] -> ComputationM ()
|
setListElem :: Show a => Token a -> Token [a] -> ComputationM ()
|
||||||
setListElem a outer = do
|
setListElem a outer = do
|
||||||
tell [DependencyUntyped d (show d)]
|
tellDep (Dependency a SetListElem outer)
|
||||||
pure NoToken
|
pure NoToken
|
||||||
where d = Dependency a SetListElem outer
|
|
||||||
|
|
||||||
run :: (Show a, Show b, IsFunction f a b) => f -> Token a -> ComputationM b
|
run :: (Show a, Show b, IsFunction f a b) => f -> Token a -> ComputationM b
|
||||||
run f input = genDependency (Dependency input (Function f))
|
run f input = genDependency (Dependency input (Function f))
|
||||||
|
|
Loading…
Reference in New Issue