In Rust when you have an operation that can result in an error then it returns a Result which contains either an Ok or Err. We return the Result if we expect to recover from an error. Example in rust:

match guess.parse() {
	Ok(number) => println!("You guessed well"),
	Err(_) => println!("Cant parse your guess"),
};

In gleam, we have a build in Result(value, error) in the standard library.

case guess == 0 {
	True -> Error(NotLuckyEnough)
	False -> Ok(money)
}

Resources