logo

Crowdly

Types Haskell is a statically typed language, which means (among other thin...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Types

Haskell is a statically typed language, which means (among other things) that the compiler knows statically — before and without the need to execute a piece of source code — what its type is.

In the REPL, you can obtain this information with the special :t meta-instruction (instructions starting with a colon and a letter are typically instructions directed towards the REPL and only valid there).

For example, we can ask: what is the type of the literal True?

ghci> :t True

True :: Bool

The REPL responds that the expression True has type (::) Bool

.

(In general, Haskell places types "after". This is similar to Python, Scala, TypeScript, and many other languages; but different than C and Java, in which types generally are placed "before", for example in the signature of functions.)

A character literal is written within single quotes. What is the type of 'a'?

(Just answer with the type, not the full REPL output.)

More questions like this

Want instant access to all verified answers on www.icorsi.ch?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!