<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 7, 2015 at 3:35 AM, Herbert Valerio Riedel <span dir="ltr"><<a href="mailto:hvr@gnu.org" target="_blank">hvr@gnu.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">--8<---------------cut here---------------start------------->8---<br>
import Control.Applicative as A (Applicative(..))<br>
<span class=""><br>
data Maybe' a = Nothing' | Just' a<br>
<br>
instance Functor Maybe' where<br>
    fmap f (Just' v) = Just' (f v)<br>
    fmap _ Nothing'  = Nothing'<br>
<br>
</span>instance A.Applicative Maybe' where<br>
<span class="im">    pure = Just'<br>
    f1 <*> f2   = f1 >>= \v1 -> f2 >>= (pure . v1)<br>
<br>
instance Monad Maybe' where<br>
    Nothing' >>= _  = Nothing'<br>
    Just' x  >>= f  = f x<br>
<br>
    return = pure -- "deprecated" since GHC 7.10<br>
--8<---------------cut here---------------end--------------->8---<br>
<br></span></blockquote><div><br></div><div>Alternately,</div><div><br></div><div><span style="font-size:12.8px"><font face="monospace, monospace">import Control.Applicative</font></span></div><div><font face="monospace, monospace">import Prelude<br style="font-size:12.8px"><span class="im" style="font-size:12.8px"><br>data Maybe' a = Nothing' | Just' a<br><br>instance Functor Maybe' where<br>    fmap f (Just' v) = Just' (f v)<br>    fmap _ Nothing'  = Nothing'<br><br></span><span style="font-size:12.8px">instance Applicative Maybe' where</span><br></font></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="im">
</span><span class=""><font color="#888888">-- hvr<br>
</font></span><div class=""><div class="h5">_______________________________________________<br>
Haskell-prime mailing list<br>
<a href="mailto:Haskell-prime@haskell.org">Haskell-prime@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime</a><br>
</div></div></blockquote></div><br></div></div>