Skip to content

Instantly share code, notes, and snippets.

@jszmajda
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jszmajda/90be5ebf1aa7304b53b4 to your computer and use it in GitHub Desktop.
Save jszmajda/90be5ebf1aa7304b53b4 to your computer and use it in GitHub Desktop.
Text.Printf return type polymorphism example
Prelude> import Text.Printf
Prelude Text.Printf> printf "%0.2f\n" 3.14159 -- will write the line to STDOUT
3.14
Prelude Text.Printf> printf "%0.2f\n" 3.14159 :: String
"3.14\n"
Prelude Text.Printf> :t printf "%0.2f\n" 3.14159 :: IO ()
printf "%0.2f\n" 3.14159 :: IO () :: IO ()
Prelude Text.Printf> :t printf "%0.2f\n" 3.14159 :: String
printf "%0.2f\n" 3.14159 :: String :: String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment