Haskell's type safety is second to none only to dependently-typed languages. But there is some deep magic going on with Text.Printf that seems rather type-wonky.

> printf "%d\n" 3
3
> printf "%s %f %d" "foo" 3.3 3
foo 3.3 3

What is the deep magic behind this? How can the Text.Printf.printf function take variadic arguments like this?

What is the general technique used to allow for variadic arguments in Haskell, and how does it work?

(Side note: some type safety is apparently lost when using this technique.)

> :t printf "%d\n" "foo"
printf "%d\n" "foo" :: (PrintfType ([Char] -> t)) => t
Edit
Report