[Haskell-cafe] YAWQ (Yet Another Wash Question)

Jules Bean jules at jellybean.co.uk
Thu Feb 24 12:22:40 EST 2005

On 24 Feb 2005, at 16:42, 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:

Well, how could this possibly work (that is, how could 'x' be visible 
at the point of submission)? If you go down the 'else' branch, what 
value should x have?

The scoping rule is like that for a very good reason...

Once you know what value x is supposed to have down the else branch 
then you will be able to do something like:

x <- if cond then textInputField ... else return ...


More information about the Haskell-Cafe mailing list