不在haskell中编译printf

Tas*_*las 1 haskell

伙计们请告诉我为什么这不是编译

putStrLn("The average number of fans for the films of " ++ actor ++ " is : " ++ printf "%.2f\n" (show(countAveFans actor testDatabase))
Run Code Online (Sandbox Code Playgroud)

它很简单但我不能想为什么它不起作用.我尝试将整个事物转换为字符串并取出2小数点打印出来.谢谢

Lee*_*Lee 7

你需要提供一个RealFloat而不是一个Stringprintf删除调用show:

putStrLn $ "The average number of fans for the films of " ++ actor ++ " is : " ++ (printf "%.2f\n" $ countAveFans actor testDatabase)
Run Code Online (Sandbox Code Playgroud)