Haskell's ($) is a magic operator?
Yes, there's a small amount of compiler magic around ($)
to handle impredicative types. It was introduced because everyone expects
runST $ do
foo
bar
baz
to typecheck, but it cannot normally. For more details see here (search runST
), this email, and this email. The short of it is that there's actually a special rule in the type-checker specifically for ($)
which gives it the ability to resolve the common case of impredicative types.