Documentation
¶
Overview ¶
Maybe Monad represents the presence `Just` or an absence `Nothing` of a value. It is commonly used to handle computations that may or may not return a result, or computations that can potentially fail.
Maybe monad is particularly useful when dealing with operations that can return `nil` values, as it provides a way to handle such cases in a more structured and safe manner. Maybe monad removes the need for imperative and explicit `nil` pointer checks, which effectively make the code more noisy hiding the important domain logic. Maybe monad essentially enables you to focus solely on the "happy path".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fmap ¶
Fmap or also known as `bind` function lets non-monadic function `f` to operate on the contents of monad m a, and lifts the value to a new domain (Maybe a -> Maybe b).
Types ¶
type Maybe ¶
type Maybe[A any] struct { // contains filtered or unexported fields }
Maybe monad data type representation. May or may not contain a pointer value. Nothing is represented as a `nil` value internally.
func From ¶
From is the return operation for Maybe monad that returns either Just a or Nothing. Intended to be used with Go functions that return tuple as `val, ok`.