Skip to content
Cinch
Packages/cinch-base/Data.Option
SAMPLE API
MODULE REFERENCE

Data.Option

Values that may be absent, without sentinel values or null.

SYNOPSIS

Types and classes

Option

data Option a

Either a present value or its absence.

CONSTRUCTORS

None :: Option a

No value is present.

Some :: a -> Option a

A present value.

Functions and values

map

function§Source ↗
map :: forall a b. (a -> b) -> Option a -> Option b

Apply a function to a present value. None remains None.

EXAMPLE

map (\x -> x + 1) (Some 4)
-- Some 5

with-default

function§Source ↗
with-default :: forall a. a -> Option a -> a

Extract a present value, or return the supplied default.

EXAMPLE

with-default 0 None
-- 0