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?
You can use show:
show 3
What I want to add is that the type signature of show is the following:
show :: a -> String
And can turn lots of values into string not only type Int
.
For example:
show [1,2,3]
Here is a reference:
https://hackage.haskell.org/package/base-4.14.1.0/docs/GHC-Show.html#v:show