tur/option

stdlib/option.tur
defn

some

(some [x])

wrap a value in a some option.

xthe value to wrap

Since: Phase B1

defn

none

(none)

return the none option (NULL).

Since: Phase B1

defn

some?

(some? [o] :bool)

check whether an option contains a value.

othe option to test

Since: Phase B1

defn

option-unwrap

(option-unwrap [o] :int)

extract the value from a some option, panicking if none.

othe option to unwrap

Since: Phase B1

defn

option-free

(option-free [o])

free the heap memory for an option value.

othe option to free (may be none / NULL)

Since: Phase B1

defn

option-must

(option-must [o :ptr<void>] :int)

unwrap a some option or panic with a default message.

othe option to unwrap (:ptr<void>)

Since: Phase R4

defn

option-expect

(option-expect [o :ptr<void> msg :cstr] :int)

unwrap a some option or panic with a caller-supplied message.

othe option to unwrap (:ptr<void>)
msgthe panic message (:cstr)

Since: Phase R4

definstance

Foldable[option]

(definstance Foldable [option])

Foldable: foldl and foldr over the contained value.

definstance

Functor[option]

(definstance Functor [option])

Functor: fmap over the contained value.

definstance

Applicative[option]

(definstance Applicative [option])

Applicative: pure and ap.

definstance

Monad[option]

(definstance Monad [option])

Monad: bind (flat-map over the contained value).

definstance

Foldable[option]

(definstance Foldable [option])
definstance

Traversable[option]

(definstance Traversable [option])

Traversable: traverse with an Applicative.

definstance

Alternative[option]

(definstance Alternative [option])

Alternative: empty and alt-or.

defn

option-eq?

(option-eq? [o1 o2 cmp-fn] :bool)

compare two options using a caller-supplied comparator.

o1first option
o2second option
cmp-fncomparator of type fn [a :int b :int] :bool

Since: Phase E1

definstance

Eq[option]

(definstance Eq [option])

Eq: structural equality via option-eq?.

definstance

Clone[option]

(definstance Clone [option])

Clone: deep copy of the option struct.

Internal definitions
__foldable_option_foldl-- SINCE: Phase HKT ยง6
__foldable_option_foldr-- foldr implementation for the option Foldable instance.
__functor_option_fmap-- SINCE: Phase HKT H3
__applicative_option_pure-- pure implementation for the option Applicative instance.
__applicative_option_ap-- ap implementation for the option Applicative instance.
__monad_option_bind-- bind implementation for the option Monad instance.
__foldable_option_foldl
__foldable_option_foldr
__traversable_option_traverse-- traverse implementation for the option Traversable instance.
__alternative_option_empty-- empty implementation for the option Alternative instance.
__alternative_option_alt_or-- alt-or implementation for the option Alternative instance.
__clone_option_clone-- clone implementation for the option Clone instance.