
Hi, Am Donnerstag, den 17.11.2016, 10:43 +0800 schrieb winter:
It seems this’s a very old request, see https://wiki.haskell.org/If-t hen-else. I’d like to see following:
ifThenElse :: Bool -> a -> a -> a ifThenElse True x _ = x ifThenElse False _ y = y
+1 on that. It is strange that GHC desugars to ifThenElse¹ without this function being available anywhere. Most (all?) of the other rebindable syntax elements work out of the box as before with Prelude imported but this one. Therefore, I’d support a proposal to add ifThenElse to the prelude. It would also make teaching nicer, by pointing students to this function and saying „if then else is just syntactic sugar for it“. Slightly better than „if then else is just syntactic sugar for a hypothetical function that you can define, but that is not there.“
infixr 1 ? (?) :: Bool -> a -> a -> a (?) = ifThenElse
-1. Operators are just too scarce. Greetings, Joachim ¹ http://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/glasgow _exts.html#rebindable-syntax-and-the-implicit-prelude-import -- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org