News for hackers. Stuff that matters.
Re:Destroy All Ifs – A Perspective from Functional Programming by eru on Sunday July 17, 2016 @02:34AM (#12109256)
The problem with the Boolean is rather that people mix up the two values all the time.

The lambda also has more type safety. A Boolean is always a Boolean, but the compiler (and in a dynamic language the runtime) can tell you when you are calling your passed functions with the wrong arguments, because you mixed them up.

Re:Destroy All Ifs – A Perspective from Functional Programming by titzer on Sunday July 17, 2016 @12:08PM (#12110582)
Use an enum.
Re:Destroy All Ifs – A Perspective from Functional Programming by eru on Monday July 18, 2016 @06:43AM (#12114264)
No need to stop there. Not only use an enum, but also make it bear different types of values for different cases, and you arrive at Algebraic Datatypes. Eg, for trees you can have:

    data Tree = Empty
              | Leaf Int
              | Node Tree Tree