
Nearly - the first suggestion doesn't work because each es needs a new
panel I can't use the same one each time.
The second suggestion doesn't quite work because the x in [text :=
contents x] is not in scope of the \p function.
Thanks.
N
On Jan 7, 6:29 pm, Daniel Fischer
On Friday 07 January 2011 19:01:43, b1g3ar5 wrote:
Thanks for your reply but it doesn't quite solve the problem. This:
plist <- mapM (\x-> (panel nb [])) my_list
returns [Panel()] and works as you say, but:
elist <- mapM (\x-> (textCtrl (panel nb []) [text := contents x])) my_list
still won't work because the function panel returns a IO (Panel()) and so won't do as a parameter to textCtrl.
I can get round this by applying mapM to a list of the indices (of my_list and plist:
elist <- mapM (\ix-> (textCtrl (plist!!ix) [text := contents (my_list!! ix)])) [1..4]
but this seems a bit crap. There must be a neat way of doing this.
Depends on the semantics of panel, maybe
do whatever p <- panel nb [] es <- mapM (\x -> textCtrl p [text := contents x]) my_list moreWith es
does what you want. If panel has side effects you need for every item in the list,
do whatever es <- mapM (\x -> panel nb [] >>= \p -> textCtrl p [text:=contents x]) my_list moreWith es
ought to do it.
_______________________________________________ Haskell-Cafe mailing list Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe