In mathematics, it is often useful to talk about a binary operation such as && , || , + , * , etc. as having a personality. Identity is the value of e such that for some common binary operation <>
the following property is satisfied:
e <> x = x x <> e = x
For the above operators, they are commutative, which means x <> y = y <> x for all x and y , so we only need to check one of the above properties. For and , the binary operator && under consideration, and for or binary operator || . If we make a Cayley table for these operations, it will look like
&& | False | True ------+-------+------ False | False | False True | False | True || | False | True ------+-------+------ False | False | True True | True | True
So, as you can see, for && , if you have True && False and True && True , the answer is always the second argument to && . For || if you have False || False False || False and False || True False || True , the answer is always the second argument, so the first argument of each of them should be an identification element under these operators. Simply put:
True && x = x x && True = x False || x = x x || False = x
Thus, the preferred answer, when there are no elements to execute the on statement, is an identification element for each operation.
It may also help to think of identity elements for + and * , which are 0 and 1 respectively:
x + 0 = x = 0 + x x * 1 = x = 1 * x
You can also expand it to operations such as combining lists ( ++ with [] ), the composition of functions for functions like a -> a ( (.) With id ), as well as many others. Since this is starting to look like a template, you may ask if it is already in Haskell, and it really is. The Data.Monoid module defines the Monoid class, which abstracts this template, and its minimum definition.
class Monoid a where mempty :: a
And these are even mappend as <> for ease of use (it is not by chance that I chose it above for the general binary operator). I recommend that you look at this module and play around with its definitions. Source code is pretty easy to read and educate.