containers v0.7.0 Containers.Optional View Source

Inspired by the Maybe type in other languages this container provides a way to wrap any value and safely transform the value. This should result in less runtime errors.

Implemented Protocols

  1. Appendable
  2. Mappable
  3. Sequenceable
  4. Unwrappable
  5. Joinable

NOTE Appendable assumes that the inner value implements the Appendable protocol. Until further research is done there does not seem to be a way to ensure this is true of the inner value at compile time.

Link to this section Summary

Functions

Takes any value and puts it in the Optional container

Link to this section Types

Link to this type t() View Source
t() :: %Containers.Optional{value: any}

Link to this section Functions

Link to this function to_optional(v) View Source
to_optional(any) :: t

Takes any value and puts it in the Optional container.

Examples

iex> Containers.Optional.to_optional(1)
%Containers.Optional{value: 1}