Update value in meta map

This commit is contained in:
Chris Done 2017-10-14 17:51:13 +01:00
parent be81af0aad
commit 83dda2d479

View File

@ -351,28 +351,21 @@ newEditor (Editor printer parser renderer) input@(Input value focus) initialValu
currentValuesEv <-
switchPromptly never (fmapMaybe (pure . outputValue) streamsEv)
metas <- holdDyn (constDyn mempty) (fmapMaybe (pure . outputMeta) streamsEv)
metaDyn <-
mapDyn
(M.insert
uuid
(Meta
{ metaNode = cons initialValue
, metaParent = Nothing
, metaChildren = mempty
}))
(joinDyn metas)
pure
( Output
{ outputValue =
let outputValueEvent =
fmapMaybe
(either (const Nothing) Just)
(leftmost
[ updated parseResultDyn
, fmapMaybe (pure . Right) currentValuesEv
])
, outputMeta = metaDyn
[updated parseResultDyn, fmapMaybe (pure . Right) currentValuesEv])
currentValueDyn <- holdDyn initialValue outputValueEvent
let makeMeta v =
Meta
{ metaNode = cons v
, metaParent = Nothing
, metaChildren = mempty
}
, uuid)
metaDyn <-
combineDyn (M.insert uuid . makeMeta) currentValueDyn (joinDyn metas)
pure (Output {outputValue = outputValueEvent, outputMeta = metaDyn}, uuid)
where
visibilityToggler f =
mapDyn