:type is a GHCi command for asking what type GHCi assigns to an expression or name. Use it when a value’s printed form hides the type you intended, or when type inference has supplied a type without an explicit annotation. section 2.3.1 section 2.2
At the GHCi prompt, enter :type followed by a name or expression. The shorter command :t does the same job. GHCi reports the result as a type expression, using :: to separate the name or expression from its type. section 2.3.1 section 2.2
Checking a type synonym
An Alphabet is defined as a synonym for [Char], so its values print like ordinary strings. Querying the names confirms that GHCi still reports the more meaningful Alphabet type: ghci> :type lowerAlphabet lowerAlphabet :: Alphabet ghci> :t digits digits :: Alphabet This lets a program use a readable domain name while retaining the underlying list-of-characters representation. section 2.3.1 section 2.3.1
Use nearby GHCi commands for related inspection and workflow tasks:
- Use :info, or :i, to see how a type or value is defined; for example, FilePath is shown as a synonym for String. section 2.3.1
- Use :reload, or :r, after saving module changes so the updated definitions are available in GHCi. Reloading removes locally entered definitions and values. section 2.3.1
- Write explicit top-level type expressions when defining module functions and values, even though Haskell can often infer them. section 2.2
ghci> :type lowerAlphabet lowerAlphabet :: Alphabet ghci> :type upperAlphabet upperAlphabet :: Alphabet ghci> :type digits digits :: Alphabet
Compare the values printed as strings with the types GHCi reports for the alphabet definitions. section 2.3.1
