Haskell: Converting Int to String

Squirrelsama picture Squirrelsama · May 6, 2010 · Viewed 160.9k times · Source

I know you can convert a String to an number with read:

Prelude> read "3" :: Int
3
Prelude> read "3" :: Double 
3.0

But how do you grab the String representation of an Int value?

Answer

Chuck picture Chuck · May 6, 2010

The opposite of read is show.

Prelude> show 3
"3"

Prelude> read $ show 3 :: Int
3