In chapter 4 of Erik Meijer on Functional Programming Fundamentals, he essentially writes:
True  &&& x | x == True  = True
            | x == False = False
Isn't this unnecessarily verbose? Couldn't I just write:
True  &&& x = x
or even:
(&&&) True  = id
(&&&) False = const False          
By the way, how come I cannot write the following?
(True  &&&) = id
(False &&&) = const False          
ghci responds with:
Parse error in pattern: True &&&
                Yes, the way you define it is better. From the Prelude:
True  && x = x
False && _ = False
You can only use sections in expressions, not in patterns.  There is no deep reason why (True &&) shouldn't be allowed in a pattern.  But it's such a rare thing to want that I don't think it's worth the complication.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With