One reason isupdated after question update
I feel that variadic functions are hard in haskell. What would be the type of such a function? a -> b -> c -> ... ? Anotherpython version:
"-g -I{headers_dir} -O2".format(**locals())
is an abuse of the language. So I wouldn't say that just using something like:python really offers local variable interpolation in strings. In fact, few languages have it.
Answering sprintf :: Show awhy =>language StringX ->doesn't [a]have ->feature StringY
feels terribly unsafe in haskell. Remember often comes down to saying that unsafe function should be avoidedthe designers did not feel that it was worth it. In the case of local variable interpolation in strings, because debugging themit is harder thanvery much a niche thing used in other languages focused on command line scripts. Which Haskell is not. The fact that you can do it in python only comes from the (no callstack, less debug toolstoo?) powerful reflection facilities of the language. An alternative could be:
Now why is sprintf :: Show a => String -> [a] -> Either String StringText.InterpolatedString.Perl6
But it so complex to use? It relies on quasiquotations, which is not that much betterpart of the haskell language. Text.Printf provide a nicer solution withIt is a type classghc language extension, but which will also throw an exceptionso you have to declare its usage somewhere. If you exclude the library installation & the language extension declaration, its usage is not really more complex than in case of mismatchyour other examples, and is more safe.
You can actually have some form of typesafe printf with type families ( see fun with types paper part 4)