I have a block of code
main = do
args <- getArgs --args is a list.
...
let finalMappedContents = addUpSameWord mappedContents
For the final IO statement, I want to print out the type of finalMappedContents. How can I do this? I know of the typeOf function, but I'm not completely sure how to use that here.
You can use showsTypeRep
in order to get the String
representation of the type:
λ> let foo = "Foo"
λ> import Data.Typeable
λ> putStrLn $ showsTypeRep (typeOf foo) ""
[Char]
In your case it would be:
putStrLn $ showsTypeRep (typeOf finalMappedContents) ""
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.