2008/5/1 Galchin, Vasili <
vigalchin@gmail.com>:
Sorry .. my example was bad. I want to use "x" .. in then branch where it occur ...
e.g.
bonzo :: Maybe Bozo -> IO ()
bonzo maybe_bozo = do
case maybe_bozo of
Just (Bozo x) -> x ........
_ -> .........
??
Sure, after pattern-matching on the x (using a case, or a top-level pattern match), you are free to use x in the resulting branch. For example:
bonzo (Just (Bozo x)) = print (show x) >> return x -- or whatever
bonzo Nothing = return ()
-Brent