-
Notifications
You must be signed in to change notification settings - Fork 4
2015 003a Option
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.
val isNone : 'a option -> bool
val fold : ('a * 'b -> 'b) -> 'b -> 'a option -> 'b
-
isNone opt
returnstrue
ifopt
isNONE
andfalse
otherwise. -
fold f init opt
returnsinit
ifopt
isNONE
andf(x, init)
ifopt
isSOME x
.
Since isSome
is part of the pervasive environment, isNone
should also be
visible without qualification.
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.