Overview
In the Haskell community, there is a well-(un)known question about the filter function - does the filter predicate means to TAKE or to DROP (check example)? Boolean Blindness smell occurs in a situation in which a function or method that operates on bool-s destroys the information about what boolean represents. It would be much better to have an expressive equivalent of type boolean with appropriate names in these situations. For the filter function, it could be of type Keep defined as Keep = Drop | Take.
This smell is in the same family as Uncommunicative Names and Magic Numbers.
Problems
Neither in real life one can answer just yes/no without ever confusing interlocutor to every single closed question that may possible.
Example
1data Bool = False | True
2filter :: (a -> Bool) -> [a] -> [a]Refactoring
- Introduce New Type
Sources
- ORIGIN