July 2023
Intermediate to advanced
670 pages
17h 13m
English
Haskell variables must start with a lowercase letter and can contain letters, numbers, underscores, and the single quote character (‘). You can use Unicode letters in Haskell variable names, but we’ll stick to ASCII in this book. By convention, Haskell variables use camelCase. Here are some examples:
| | helloWorld = "Hello, World" |
| | number5 = 5 |
| | snake_case_variable = True |
| | number5' = 6 |
As you might expect, we can also assign a variable to another variable:
| | five = 5 |
| | number = five |
In ghci you can enter the name of a variable to see its value:
| | λ helloGeorge = "Hello, George" |
| | λ helloGeorge |
| | "Hello, George" |
| | λ five = 2 + 3 |
| | λ five |
| | 5 |
You can also re-use a variable name in ghci. For example, let’s create ...