containers v0.1.1 Containers.Optional

Inspired by the Maybe type in other languages this container provides away to wrap any value and safely able to transform the value. This will provide less runtime errors.

Implemented Protocols

  1. Appenedable
  2. Mappable
  3. Sequenceable
  4. Unwrappable

NOTE Appenedable assumes that the inner value is implements the Appenedable 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.

Summary

Functions

Takes any value and puts it in the Optional container

Types

t()
t() :: %Containers.Optional{value: nil | any}

Functions

to_optional(v)
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}