Novah Documentation

novah.result

Functions to work with values that may fail. Result should always be prefered over throwing exceptions.

Types

Declarations


map

visibility: public
type: (a -> b) -> Result a err -> Result b err

Maps a function over this result if it is ok. Runtime: O(1)


mapErr

visibility: public
type: (a -> b) -> Result ok a -> Result ok b

Maps a function over this result if it is an error. Runtime: O(1)


unwrap

visibility: public
type: Result a b -> a

Extracts the value out of this result. Unsafe: Will thrown an exception if the result is an error.


isOk

visibility: public
type: Result a b -> Boolean

Returns true if this result is ok.


isErr

visibility: public
type: Result a b -> Boolean

Returns true if this result is an error.


ok

visibility: public
type: Result a b -> Option a

Transforms this result into an option discarding the error.


err

visibility: public
type: Result a b -> Option b

Transforms this result into an option discarding the success.


handle

visibility: public
type: (a -> c) -> (b -> c) -> Result a b -> c

Handles this result by either applying the first function in case the result is ok, or the second, if the result is an error.