[Haskell-cafe] Evaluation of IO actions in record assignment
Tillmann Rendel
rendel at rbg.informatik.tu-darmstadt.de
Mon Jul 9 12:12:27 EDT 2007
Adde wrote:
> signatureEntry <- xmlGetWidget xml castToEntry "signatureEntry"
> passwordEntry <- xmlGetWidget xml castToEntry "passwordEntry"
> repeatEntry <- xmlGetWidget xml castToEntry "repeatEntry"
> return UserPanel {userPanelSignatureEntry = signatureEntry,
> userPanelPasswordEntry = passwordEntry,
> userPanelRepeatEntry = repeatEntry}
Use one of the general monadic combinators given in Control.Monad:
liftM3 UserPanel (xmlGetWidget xml castToEntry "signatureEntry")
(xmlGetWidget xml castToEntry "passwordEntry")
(xmlGetWidget xml castToEntry "repeatEntry")
or
return UserPanel
`ap` xmlGetWidget xml castToEntry "signatureEntry"
`ap` xmlGetWidget xml castToEntry "passwordEntry"
`ap` xmlGetWidget xml castToEntry "repeatEntry"
Tillmann
More information about the Haskell-Cafe
mailing list