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

haskell at list.mightyreason.com haskell at list.mightyreason.com
Mon Jul 9 11:57:18 EDT 2007

Try liftM3 from Control.Monad

let get = xmlGetWidget xml castToEntry

liftM3 UserPanel (get "signatureEntry") (get "passwordEntry") (get "repeatEntry")

Adde wrote:
> Hi.
> I'm toying around with GTK2Hs and one of the things I'm doing 
> is stuffing a bunch of widgets in a record. 
> The problem is that the function that fetches a widget from the 
> Glade file returns IO Widget while my structure contains Widget's.
> The best I've come up with is simply evaluating the actions by 
> putting the result in temporaries and then building the record. 
> Is there an easier way to accomplish this?
> signatureEntry <- xmlGetWidget xml castToEntry "signatureEntry"
> passwordEntry <- xmlGetWidget xml castToEntry "passwordEntry"
> repeatEntry <- xmlGetWidget xml castToEntry "repeatEntry"
> return UserPanel {userPanelSignatureEntry = signatureEntry,
> 	     	  userPanelPasswordEntry = passwordEntry,
> 	     	  userPanelRepeatEntry = repeatEntry}
> Thanks,
> Adde
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list