logo

Crowdly

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

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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.)

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на www.icorsi.ch?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!