One liner that I can think of avoids protection:
import Data.List howManyEqual :: Int -> Int -> Int -> Int howManyEqual abc = maximum $ 0 : (filter (> 1) . map length . group . sort) [a,b,c]
This is clearly less efficient, although it seems like overuse of the function.
It probably makes sense to use such an algorithm if your input is a huge list in which you want to calculate how many elements are equal. This is O (n log n).
source share