I am currently redesigning a piece of legacy wxHaskell using the reactive-banana and reactive-banana-wx packages. However, in order to avoid dynamic network construction (where I ran into a thread block on an MVar), I now mimic this by preconstructing a fixed set of wxHaskell widgets of which I set visibility as necessary. Visibility is set by the sink
function taking a Behavior
. However, wxHaskell requires that after all these widgets have been appropriately modified via sink
, a subsequent change of the layout of the panel holding these widgets is required. That would mean that sink
-ing actually should be part of a network, so it is an event which can be triggered and waited upon for a layout change. As it currently is, a sink
takes you 'out' of the event network, it is not possible to trigger an event after the sink
action is completed. I did try to adapt sink
to something like this:
sink' :: Frameworks t =>
w -> [Prop' t w] -> Moment t (Event t ())
sink' widget props = do
es <- mapM sink1 props
return $ unions es
where
sink1 (attr :== b) = do
x <- initial b
liftIOLater $ set widget [attr := x]
e <- changes b
return $ (\x -> unsafePerformIO $ set widget [attr := x]) <$> e
However, the unsafePerformIO
did not get executed. How can the desired behavior be achieved, i.e. allow a (wxHaskell) IO to be waited on by means of an Event
?
BarTab.hs
example, I did copy its behavior. BarTab dynamically computes an increment of a list of widgets, this increment is independent of the previous list. The increment I tried to construct however does depend on the previous list. I guess it went wrong there, and will probably retry it later on, maybe giving rise to another post. – Meredi