Search⌘ K
AI Features

Booleans

Explore Haskell's Bool data type, including values True and False. Understand how to use Boolean operators like not, &&, ||, and comparison operators such as == and /=. Learn how Haskell infers types with examples from numeric and Boolean expressions to build foundational functional programming skills.

We'll cover the following...

Let’s focus some more on Haskell’s basic data types. After all, just using arithmetic operations does not allow us to write interesting functions.

In this lesson, we will be using ghci again, which you can run from the following terminal window:

Terminal 1
Terminal
Loading...

The Bool type

Bool is the data type of truth values, named in honor of the famous logician George Boole. It contains exactly two distinct values: True and False.

Booleans can be negated with not or combined with the binary operators && (conjunction) and || (disjunction).

 ...