Logo

Programming-Idioms

History of Idiom 94 > diff from v8 to v9

Edit summary for version 9 by :
New Haskell implementation by user [JH]

Version 8

2015-11-30, 12:37:31

Version 9

2016-02-16, 19:46:07

Idiom #94 Print type of variable

Print the name of the type of x. Explain if it is a static type or dynamic type.

This may not make sense in all languages.

Idiom #94 Print type of variable

Print the name of the type of x. Explain if it is a static type or dynamic type.

This may not make sense in all languages.

Imports
import Data.Dynamic
Code
print (dynTypeRep (toDyn x))
Comments bubble
Haskell is statically typed with type erasure. But all types member of the Typeable type class can be made into dynamic types by toDyn. We print the type rep which prints the name of the dynamic type.