Gcode.Result (gcode v0.4.1)

A helper which represents a result type.

This is really just a wrapper around Erlang's ok/error tuples.

Link to this section Summary

Functions

Initialise or match an error value

Is the result an error?

Convert a successful result another result.

Initialise or match an ok value

Is the result ok?

Attempt to unwrap a result and return the inner value. Raises an exception if the result contains an error.

Link to this section Types

Link to this type

error(error)

Specs

error(error) :: {:error, error}

Specs

ok(result) :: {:ok, result}

Specs

t() :: t(any(), any())

Specs

t(result) :: t(result, any())
Link to this type

t(result, error)

Specs

t(result, error) :: ok(result) | error(error)

Link to this section Functions

Link to this macro

error(error)

(macro)

Specs

error(any()) :: Macro.t()

Initialise or match an error value

Specs

error?(t()) :: boolean()

Is the result an error?

Link to this function

map(arg, mapper)

Specs

map(t(), (any() -> t())) :: t()

Convert a successful result another result.

Link to this macro

ok(result)

(macro)

Specs

ok(any()) :: Macro.t()

Initialise or match an ok value

Specs

ok?(t()) :: boolean()

Is the result ok?

Specs

unwrap!(t()) :: any() | no_return()

Attempt to unwrap a result and return the inner value. Raises an exception if the result contains an error.