Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

communitycreator
elm
data types

# What are the data types in Elm?

Amengor-Kwapong Angela

In programming, data types refer to the different kinds of values supported by a particular programming language.

Like other programming languages, Elm also has a defined set of data types.

### Numeric data types in Elm

The numeric data type represents numeric values in Elm.

Numeric data types in Elm
 Type Function Example Number Stores numbers 5 Float Stores fractional values The result of 5/2 i.e., 2.5 Integer Stores non-fractional values The result of 5//2 i.e., 2

### String and Char data types in Elm

The String data type in Elm represents a sequence of characters. They are defined within double quotes ".

Meanwhile, the Char data type represents a single character. They are enclosed within single quotes '.

### Example

Let’s consider the word educative. We can represent the whole word containing nine characters with the String data type. Meanwhile, we can singly represent each of those nine characters with the Char data type.

String and Char data types in Elm
 Type Function example String Stores multiple characters "educative" Char Stores single characters 'e'

### Bool data type in Elm

The Bool data type in Elm supports the use of the values True and False. Boolean values are represented by the keyword Bool.

Bool data type in Elm
 Type Function Example Bool Stores the values True or False 1 == 2 returns False

### Structured data types

The Structured data type in Elm represents multiple or a collection of values in a structured format. The values can either be homogenous or heterogeneous.

Elm supports a variety of structured data types. They are:

• Tuple
• List
• Record
Structured data types in Elm
 Type Function Example Tuple Stores values of different types ("educative", 5, True, "good") List Stores multiple values of the same type myList1 = [10, 20, 30] Record Stores key-value pairs {name="educative", rating=10}

RELATED TAGS

communitycreator
elm
data types

CONTRIBUTOR

Amengor-Kwapong Angela
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time