<div dir="ltr"><div style="font-size:12.8px"><font face="Courier">(?) <$> fFlag <$> </font><span style="font-family:courier">flagEnabled </span><span style="font-size:12.8px;font-family:courier"><*> </span><span style="font-size:12.8px;font-family:courier">flagDisabled</span></div><div style="font-size:12.8px"><span style="font-family:courier"><br></span></div><div style="font-size:12.8px"><span style="font-family:courier">You probably don't want this. This performs both effects (!), regardless of the flag, but only keeps one result.</span></div><div style="font-size:12.8px"><span style="font-family:courier"><br></span></div><div style="font-size:12.8px"><span style="font-family:courier">-Edward</span></div><div style="font-size:12.8px"><span style="font-family:courier"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 16, 2016 at 11:01 PM, winter <span dir="ltr"><<a href="mailto:drkoster@qq.com" target="_blank">drkoster@qq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><font face="Courier">And here’s some other stuff i can came up with it(without obscured readability IMHO):</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">...</font></div><div><font face="Courier">   -- replacement for</font><font face="Courier"> ifM in various package, </font><span style="font-family:Courier">similar to (>>= when)</span></div><div>   </div><div><font face="Courier">   (mFlag >>= (?)) flagEnabled       </font><span style="font-family:Courier"> -- mFlag :: Monad m => m Bool</span></div><div><font face="Courier">                 $ flagDisabled</font></div><div><font face="Courier">  </font></div><div><font face="Courier">   -- nicer if-then-else in applicative style</font></div><div><font face="Courier">   (?) <$> fFlag <$> </font><span style="font-family:Courier">flagEnabled</span></div><div><span style="font-family:Courier">                 <*> </span><span style="font-family:Courier">flagDisabled</span></div><div><font face="Courier"><br></font></div><div><font face="Courier">   -- compose with predicates to define your own if</font></div><div><font face="Courier">   ifLower =  (?) . isLower</font></div><div><font face="Courier">   ifLower ‘X’ lower</font></div><div><font face="Courier">               upper</font><span style="font-family:Courier"> </span></div><div><font face="Courier">...</font></div><div><font face="Courier"><br></font></div><div><font face="Courier"><br></font></div><div><font face="Courier">Basically it's a good if-then-else replacement if you’re comfortable with point-free style.</font></div><div><div class="h5"><div><font face="Courier"><br></font></div><br><div><blockquote type="cite"><div>On 17 Nov 2016, at 11:16, winter <<a href="mailto:drkoster@qq.com" target="_blank">drkoster@qq.com</a>> wrote:</div><br class="m_-251983560361698768Apple-interchange-newline"><div><div style="word-wrap:break-word"><div><font face="Courier"><span style="font-size:14px">I’m totally aware of the existence of bool, i suppose (?) is mainly used in fully application to get a different style than if-then-else syntax, say,</span></font></div><div><font face="Courier"><span style="font-size:14px"><br></span></font></div><div><font face="Courier"><span style="font-size:14px">...</span></font></div><div><font face="Courier"><span style="font-size:14px">    isGoo <- checkGoo</span></font></div><div><font face="Courier"><span style="font-size:14px">    isGoo ? goo</span></font></div><div><font face="Courier"><span style="font-size:14px">          $ woo</span></font></div><div><font face="Courier"><span style="font-size:14px">...</span></font></div><div><font face="Courier"><span style="font-size:14px"><br></span></font></div><div><font face="Courier"><span style="font-size:14px"><br></span></font></div><div><font face="Courier"><span style="font-size:14px">But like what the wiki suggested, (?) can be used in some high-order situations. I like this operator because the mnemonic of questioning meaning.</span></font></div><div><br></div><div><br></div><br><div><blockquote type="cite"><div>On 17 Nov 2016, at 11:03, David Feuer <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>> wrote:</div><br class="m_-251983560361698768Apple-interchange-newline"><div><p dir="ltr">If ifThenElse is good for RebindableSyntax, then I'm +1 on that (but I've never played with that extension, so I don't really know). I'm -1 on (?). We already have bool, which tends to be rather more useful when partially applied.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Nov 16, 2016 9:43 PM, "winter" <<a href="mailto:drkoster@qq.com" target="_blank">drkoster@qq.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div dir="ltr" class="m_-251983560361698768m_-8486897005054858839mw-content-ltr m_-251983560361698768m_-8486897005054858839mw-geshi"><div class="m_-251983560361698768m_-8486897005054858839source-haskell m_-251983560361698768m_-8486897005054858839haskell"><pre class="m_-251983560361698768m_-8486897005054858839de1">It seems this’s a very old request, see <a href="https://wiki.haskell.org/If-then-else" target="_blank">https://wiki.haskell.org/If-th<wbr>en-else</a>. I’d like to see following:</pre><pre class="m_-251983560361698768m_-8486897005054858839de1"><br></pre><pre class="m_-251983560361698768m_-8486897005054858839de1"><span class="m_-251983560361698768m_-8486897005054858839st0">ifThenElse :: Bool -> a -> a -> a
ifThenElse</span> True  x <span class="m_-251983560361698768m_-8486897005054858839sy0">_</span> <span class="m_-251983560361698768m_-8486897005054858839sy0">=</span> x
<span class="m_-251983560361698768m_-8486897005054858839st0">ifThenElse False _ y = y</span></pre></div></div><div><br></div><div><div dir="ltr" class="m_-251983560361698768m_-8486897005054858839mw-content-ltr m_-251983560361698768m_-8486897005054858839mw-geshi"><div class="m_-251983560361698768m_-8486897005054858839source-haskell m_-251983560361698768m_-8486897005054858839haskell"><pre class="m_-251983560361698768m_-8486897005054858839de1"><span class="m_-251983560361698768m_-8486897005054858839kw1">infixr</span> <span class="m_-251983560361698768m_-8486897005054858839nu0">1</span> <span class="m_-251983560361698768m_-8486897005054858839sy0">?</span>
<span class="m_-251983560361698768m_-8486897005054858839br0">(</span><span class="m_-251983560361698768m_-8486897005054858839sy0">?</span><span class="m_-251983560361698768m_-8486897005054858839br0">)</span> <span class="m_-251983560361698768m_-8486897005054858839sy0">::</span> <span class="m_-251983560361698768m_-8486897005054858839kw4">Bool</span> <span class="m_-251983560361698768m_-8486897005054858839sy0">-></span> a <span class="m_-251983560361698768m_-8486897005054858839sy0">-></span> a <span class="m_-251983560361698768m_-8486897005054858839sy0">-></span> a
<span class="m_-251983560361698768m_-8486897005054858839br0">(</span><span class="m_-251983560361698768m_-8486897005054858839sy0">?</span><span class="m_-251983560361698768m_-8486897005054858839br0">)</span> <span class="m_-251983560361698768m_-8486897005054858839sy0">=</span> ifThenElse</pre><div><br></div></div></div><div><pre class="m_-251983560361698768m_-8486897005054858839de1"><span class="m_-251983560361698768m_-8486897005054858839kw1">in Date.Bool module, it will have advantages that:</span></pre><pre class="m_-251983560361698768m_-8486897005054858839de1"><span class="m_-251983560361698768m_-8486897005054858839kw1"><br></span></pre><pre class="m_-251983560361698768m_-8486897005054858839de1"><span class="m_-251983560361698768m_-8486897005054858839kw1">+ It’s more composable than syntax.  </span></pre><pre class="m_-251983560361698768m_-8486897005054858839de1"><span class="m_-251983560361698768m_-8486897005054858839kw1">+ Write (xxx ? yyy $ zzz) instead of (if xxx then yyy else zzz) is more consistent with (f . g $ x) style, and save key strokes.</span></pre><pre class="m_-251983560361698768m_-8486897005054858839de1"><span class="m_-251983560361698768m_-8486897005054858839kw1">+ In module with RebindableSyntax enabled, you can import </span>ifThenElse to get default behavior.</pre><pre class="m_-251983560361698768m_-8486897005054858839de1"><br></pre><pre class="m_-251983560361698768m_-8486897005054858839de1">Whether or not to be exported by Prelude is another question, but Data.Bool seems a good place to start with.</pre><pre class="m_-251983560361698768m_-8486897005054858839de1"><br></pre><pre class="m_-251983560361698768m_-8486897005054858839de1">Cheers~</pre><pre class="m_-251983560361698768m_-8486897005054858839de1">Winter</pre></div></div></div><br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/libraries</a><br>
<br></blockquote></div></div>
</div></blockquote></div><br></div></div></blockquote></div><br></div></div></div><br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>