What Haskell is doing there is basically just a kind of syntactic sugar around a pattern match, which is (to a very rough approximation) basically a super-powerful switch. Like a switch, the compress function knows about all of the branches statically, even if at runtime it dynamically selects which branch to take based on the structure of its arguments. And the structure of its arguments is "closed": it knows at compile-time all the different forms they can take.
Haskell achieves dynamic dispatch through typeclasses, and it can do multiple dispatch with the MultiParamTypeClasses extension. With these a caller doesn't need to know about the implementation it's invoking, and it doesn't need to know in advance anything about the possible values of its arguments beyond that they have an implementation that can be used - typeclasses are open, you can always define new implementations without updating every caller that uses them.
It's not just Haskell, though. Like I said, Erlang/Elixer also support this, and it enables writing some really elegant code.
multi sub compress([]) { () }
multi sub compress([$x]) { $x }
multi sub compress([$x, @ys [$y, *]]) {
$x === $y ?? compress(@ys) !! ($x, |compress(@ys))
} (defn greet
([] "Hello!")
([name] (str "Hello, " name "!"))
([name title] (str "Hello, " title " " name "!")))
Which one could argue is cleaner for multiple arguments, but you can't pattern match on arguments themselves this way (but you can using multimethod)