Don't duplicate token ids in lists
This commit is contained in:
parent
c588dc1f56
commit
8184160035
|
@ -38,8 +38,11 @@ newtype ComputationM' a = ComputationM { unComputationM :: WriterT [DependencyUn
|
||||||
|
|
||||||
type ComputationM a = ComputationM' (Token a)
|
type ComputationM a = ComputationM' (Token a)
|
||||||
|
|
||||||
|
evalComputationM' :: Int -> ComputationM () -> ([DependencyUntyped], Int)
|
||||||
|
evalComputationM' top m = runState (execWriterT (unComputationM m)) top
|
||||||
|
|
||||||
evalComputationM :: ComputationM () -> [DependencyUntyped]
|
evalComputationM :: ComputationM () -> [DependencyUntyped]
|
||||||
evalComputationM m = evalState (execWriterT (unComputationM m)) 0
|
evalComputationM m = fst (evalComputationM' 0 m)
|
||||||
|
|
||||||
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 = do
|
genDependency g = do
|
||||||
|
@ -76,7 +79,11 @@ saveFile = runIO SaveFile
|
||||||
runPandoc = runIO RunPandoc
|
runPandoc = runIO RunPandoc
|
||||||
|
|
||||||
mapComputationM :: (Show a, Show b) => (Token a -> ComputationM b) -> Token [a] -> ComputationM [b]
|
mapComputationM :: (Show a, Show b) => (Token a -> ComputationM b) -> Token [a] -> ComputationM [b]
|
||||||
mapComputationM f input = genDependency (Dependency input (MapComp (evalComputationM m)))
|
mapComputationM f input = do
|
||||||
|
top <- get
|
||||||
|
let (res, top') = evalComputationM' top m
|
||||||
|
put top'
|
||||||
|
genDependency (Dependency input (MapComp res))
|
||||||
where m :: ComputationM ()
|
where m :: ComputationM ()
|
||||||
m = do
|
m = do
|
||||||
inp <- getListElem
|
inp <- getListElem
|
||||||
|
|
Loading…
Reference in New Issue