[Haskell-cafe] elementary Maybe Monad problem .. sigh

Claude Heiland-Allen claudiusmaximus at goto10.org
Thu May 1 20:48:59 EDT 2008


Galchin, Vasili wrote:
> 
> data Bozo =
>     Bozo {
>       id :: Int
>     }
> 
> bonzo :: Maybe Bozo -> IO ()
> bonzo   maybe_bozo = do
>    if maybe_bozo == (Just (Bozo  x))
>       then
>          return ()
>       else
>          return ()
> ~ 
 >
 > I want "x" to be a pattern that matches "id" .... ??

Try:

bonzo (Just (Bozo x)) = return ()
bonzo Nothing         = return ()

> Kind regards, Vasili


Claude
-- 
http://claudiusmaximus.goto10.org


More information about the Haskell-Cafe mailing list