
Here is a simpler case of what I want to do ..
1) To function1 pass in (Maybe Int).
2) If "Nothing" then pass nullPtr to C function.
3) If "Just 1", then pass a pointer to a "1" to teh same C function.
Thanks, Vasili
On Thu, May 1, 2008 at 8:18 PM, Galchin, Vasili
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 ........ _ -> .........
??
Thanks, V.
On Thu, May 1, 2008 at 7:50 PM, Luke Palmer
wrote: 2008/5/2 Galchin, Vasili
: data Bozo = Bozo { id :: Int }
bonzo :: Maybe Bozo -> IO () bonzo maybe_bozo = do if maybe_bozo == (Just (Bozo x)) then return () else return ()
bonzo maybe_bozo = case maybe_bozo of Just (Bozo x) -> return () _ -> return ()
Or equivalently:
bonzo (Just (Bozo x)) = return () bonzo _ = return ()
You should watch out for your use of id as a field name, since id is a builtin function and you will get ambiguity errors.
Luke