<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>&nbsp;&nbsp;&nbsp; return&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Just<br>&nbsp;&nbsp;&nbsp; fail&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Nothing<br>&nbsp;&nbsp;&nbsp; Nothing&nbsp; &gt;&gt;= f = Nothing<br>&nbsp;&nbsp;&nbsp; (Just x) &gt;&gt;= f = f x<br>&nbsp;&nbsp; &nbsp;<br>instance MonadPlus Maybe where<br>&nbsp;&nbsp;&nbsp; mzero&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = Nothing<br>&nbsp;&nbsp;&nbsp; Nothing `mplus` x = x<br>&nbsp;&nbsp;&nbsp; x `mplus` _&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = x<br><br>================<br><br>[michael@localhost ~]$ ghci<br>GHCi, version 6.10.1: http://www.haskell.org/ghc/&nbsp; :? for help<br>Loading package ghc-prim ...
 linking ... done.<br>Loading package integer ... linking ... done.<br>Loading package base ... linking ... done.<br>Prelude&gt; Just 3 &gt;&gt;= (1+)<br><br>&lt;interactive&gt;:1:0:<br>&nbsp;&nbsp;&nbsp; No instance for (Num (Maybe b))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arising from a use of `it' at &lt;interactive&gt;:1:0-14<br>&nbsp;&nbsp;&nbsp; Possible fix: add an instance declaration for (Num (Maybe b))<br>&nbsp;&nbsp;&nbsp; In the first argument of `print', namely `it'<br>&nbsp;&nbsp;&nbsp; In a stmt of a 'do' expression: print it<br>Prelude&gt; <br><br></td></tr></table><br>