Let's use what we've learned so far in this chapter to write a small program that creates a deck of cards, shuffles it, and draws five cards from the top of the deck. To do so, we'll use Belt's Option and List modules, as well as the fast pipe operator.
Using Belt
Option module
Belt's Option module is a collection of utility functions for working with the option type. For example, to unwrap an option and throw a runtime exception if the option's value is None, we can use getExn:
let foo = Some(3)->Belt.Option.getExn;
Js.log(foo); /* 3 */
let foo = None->Belt.Option.getExn;
Js.log(foo); /* raises getExn exception */
Belt functions that are able to throw runtime exceptions always have the Exn...