Hello haskell-cafe@
I'm writing a GUI app in Haskell and bindings to the widget toolkit i'm using in parallel. These bindings are very simple and all its functions have return type (IO something).
So far so good, i wrote the following code to create an config window:
createConfigUI root = do
box <- Box.add root
-- first field
addToPackEnd box =<< do
f <- Fr.add box
setPartText f Nothing "E-mail"
setPartContent f Nothing =<< do
box <- Box.add box
addToPackEnd box =<< do
e <- Ent.add box
Ent.singleLineSet e True
-- Here
onEvent "changed,user" e $ do
reactOnUserInput e
objectShow e
return e
objectShow box
return box
objectShow f
return f
-- next field
addToPackEnd box =<< do
...
Initially, i was quite satisfied with flipped bind use for creating UI elements and arranging them. Nested do scopes allow copypasting code without renaming variables and also provide some visual representation on widget hierarchy.
But at some point i need to return some stuff from some inner do block into outmost. For example, at the line with comment "Here" i defined