Skip to Content
Effective Haskell
book

Effective Haskell

by Rebecca Skinner
July 2023
Intermediate to advanced
670 pages
17h 13m
English
Pragmatic Bookshelf
Content preview from Effective Haskell

Creating New Variables

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Grokking Functional Programming

Grokking Functional Programming

Michal Plachta
Grokking Algorithms

Grokking Algorithms

Aditya Bhargava
The Rust Programming Language, 2nd Edition

The Rust Programming Language, 2nd Edition

Steve Klabnik, Carol Nichols

Publisher Resources

ISBN: 9798888650400Errata Page