[Haskell-cafe] Re: Evaluation of IO actions in record assignment

Adde adde at trialcode.com
Mon Jul 9 19:22:41 EDT 2007


> 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

Thanks!

The problem is i really like specifying which fields in the record are assigned
what. It's pretty easy to mess things up and for example assign the
password-entry to the signature-field using your examples.

Is there nothing I can do to xmlGetWidget to evaluate the actions when assigning?

return UserPanel {
  userPanelSignatureEntry = *magic* xmlGetWidget xml castToEntry "signatureEntry",
  userPanelPasswordEntry = *magic* xmlGetWidget xml castToEntry "passwordEntry",
  userPanelRepeatEntry = *magic* xmlGetWidget xml castToEntry "repeatEntry"}



More information about the Haskell-Cafe mailing list