Skip to content
John Reppy edited this page Sep 2, 2015 · 1 revision
structure Option : OPTION

We propose two new functions for the Option module.

This page is part of proposal 2015-003.


Synopsis

val isNone : 'a option -> bool
val fold   : ('a * 'b -> 'b) -> 'b -> 'a option -> 'b

Description

  • isNone opt returns true if opt is NONE and false otherwise.

  • fold f init opt returns init if opt is NONE and f(x, init) if opt is SOME x.

Discussion

Since isSome is part of the pervasive environment, isNone should also be visible without qualification.

Rationale

The isNone function provides a convienient test that was omitted from the original Basis Library. Likewise, the fold function fills a hole in the specification.