Add ifThenElse and (?) to Data.Bool

Edward Kmett ekmett at gmail.com
Thu Nov 17 04:02:10 UTC 2016


I'm pretty strongly -1 on adding (?). It is one of the few single character
operators available to the average user out of the box and this is a space
where we already have established combinators. It is a valuable portion of
the namespace to spend and each approach we offer means more inessential
complexity to newcomers to the language.

Given the existence of bool today I'm weakly -1 on ifThenElse. That said,
if we were to add RebindableSyntax support for it, I think that I'd
personally flip around to being in favor. It is a much more clear thing for
RebindableSyntax to call out to than something called "bool" that comes
with a different argument order.

These are just my personal feelings on the matter, and not any sort of
"cast in stone" CLC judgments.

-Edward

On Wed, Nov 16, 2016 at 9:43 PM, winter <drkoster at qq.com> wrote:

> It seems this’s a very old request, see https://wiki.haskell.org/If-then-else. I’d like to see following:
>
>
> ifThenElse :: Bool -> a -> a -> a
> ifThenElse True  x _ = xifThenElse False _ y = y
>
>
> infixr 1 ?(?) :: Bool -> a -> a -> a(?) = ifThenElse
>
>
> in Date.Bool module, it will have advantages that:
>
>
> + It’s more composable than syntax.
>
> + Write (xxx ? yyy $ zzz) instead of (if xxx then yyy else zzz) is more consistent with (f . g $ x) style, and save key strokes.
>
> + In module with RebindableSyntax enabled, you can import ifThenElse to get default behavior.
>
>
> Whether or not to be exported by Prelude is another question, but Data.Bool seems a good place to start with.
>
>
> Cheers~
>
> Winter
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20161116/699779ec/attachment.html>


More information about the Libraries mailing list