how to combine error with printf in haskell

70 views Asked by At

I found the Haskell module Text.Printf. It provides a sort of C-like printf. For example printf "hi %d\n" 42 will produce the string "hi 42\n".

That is pretty neat. Now something like error $ printf "hi %d\n" 42 aborts the program with the error message. That is also neat.

But I would like to make a more general function abort such that abort "hi %d\n" 42 has the same effect. In other words I want to combine error with printf. But it is completely unclear to me how to do that, because of printf accepting a variable number of arguments.

Does anyone know how to do this?

0

There are 0 answers