09 Exceptions vs. Options and More Application Operators

We've implemented stacks and queues with lists now! The only difference in our data structures themselves is our use of exceptions and options.

Exceptions make it easy to pipeline operators! You can just keep adding operations as you go.

Options make that a bit trickier.

Uh oh... We get a type checking error because dequeue returned an option, while enqueue expected an int list, not an int list option.

One way to fix this would be to write a new pipeline operator to deal with this. Recall the definition of the pipeline operator:

let ( |> ) x f = f x

This is under the standard library as Option.map.

What if we wanted to dequeue after that?

Well now we have a double option. That's not right, let's write a new pipeline operator to fix it.