Primitives in Haskell

Find this useful? Support us: Star on GitHub 6
Category: Datatypes | Language: Haskell

In Haskell, primitive types are the most basic types that are built into the language and do not require any special libraries to be used. These types include:

1. Int - represents integers, which are whole numbers without decimal points. It can be positive, negative, or zero.

Example:

x :: Int
x = 5

2. Integer - represents arbitrary-precision integers, which can be as large as the memory of the computer can accommodate.

Example:

y :: Integer
y = 123456789012345678901234567890

3. Float - represents floating-point numbers, which are numbers with a decimal point.

Example:

z :: Float
z = 3.14

4. Double - represents double-precision floating-point numbers, which are floating-point numbers with higher precision than Float.

Example:

a :: Double
a = 3.14159265359

5. Char - represents characters, which can be any character from the Unicode character set.

Example:

b :: Char
b = 'a'

6. Bool - represents Boolean values, which can be True or False.

Example:

c :: Bool
c = True

Overall, primitive types are the building blocks of Haskell programming and are used to create more complex types and structures.