1
 2
 3
 4
 5
 6
 7
 8
 9
10
import Data.List

check :: [Int] -> Bool
check xs = all foo $ tails xs
 where
  foo []     = True
  foo (x:xs) = all (EQ /=) &&& ((1 >=) . length . group) $ map (compare x) xs

(&&&) :: (a -> Bool) -> (a -> Bool) -> (a -> Bool)
(p &&& q) x = if p x then q x else False