
Jeremy Shaw
I am making a wild guess because I do not have all the information in front of me right now but would this work ?
... do x <- if cond
then textInputField ... else return ()
... Let me make another guess, probably an even wilder one, ... You have to return a common type for both branches of the if. In the code snippet from above, you either get back a handle to a text input field or () --- so the types won't fit. To unify the types of both branches, I guess you have to introduce an new "wrapper" data type that *mabye* holds a handle of an input field *m* with return value *a* and validity flag *x*. data MaybeInputField m a x = MaybeInputField (Maybe (m a x)) It is important that all "input field type constructors" take two type arguments---one for the return type, and another one for the validity. Otherwise you won't be able to pass the input field to a submit button. (MaybeInputField TexxtInputField) for example fits into that scheme. With that in place, you may be able to write something like the following ... ... do mH <- if cond then do h <- textInputField ... return (MaybeInputField (Just h)) else return (MaybeInputField Nothing) -Matthias
On Feb 24, 2005 08:42 AM, John Goerzen
wrote: Thanks for everyone that's helped me out with my Wash questions. I have one more.
I have a textInputField that I only want to display on a form in certain cituations. I can't figure out how to make this work. For instance:
... do if cond then x <- textInputField ... else () ... submit ...
Well, two problems there... first, the scope of the x doesn't reach to the submit. Second, there's a type issue. So I thought maybe I could figure out something like this:
... do x <- if cond then textInputField ... else ()
still stuck with the typing problem.
So I thought maybe something like this...
... do let x = if cond then Just $ textInputField ... else Nothing
Though I suspect this won't work either, since the textInputField won't actually be processed at the right place in the program.
I then thought maybe I could kludge by this with a hidden field, but I can't find one of those, either.
Ideas, anyone?
Thanks, John
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
--
This message contains information which may be confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender and delete the message. Thank you. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Matthias Neubauer | Universität Freiburg, Institut für Informatik | tel +49 761 203 8060 Georges-Köhler-Allee 79, 79110 Freiburg i. Br., Germany | fax +49 761 203 8052