<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Why doesn't this work?<br><br>Michael<br><br>================<br><br>data Maybe a = Nothing | Just a<br><br>instance Monad Maybe where<br> return = Just<br> fail = Nothing<br> Nothing >>= f = Nothing<br> (Just x) >>= f = f x<br> <br>instance MonadPlus Maybe where<br> mzero = Nothing<br> Nothing `mplus` x = x<br> x `mplus` _ = x<br><br>================<br><br>[michael@localhost ~]$ ghci<br>GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help<br>Loading package ghc-prim ...
linking ... done.<br>Loading package integer ... linking ... done.<br>Loading package base ... linking ... done.<br>Prelude> Just 3 >>= (1+)<br><br><interactive>:1:0:<br> No instance for (Num (Maybe b))<br> arising from a use of `it' at <interactive>:1:0-14<br> Possible fix: add an instance declaration for (Num (Maybe b))<br> In the first argument of `print', namely `it'<br> In a stmt of a 'do' expression: print it<br>Prelude> <br><br></td></tr></table><br>