Containers
Containers are functional like data structures that help provide greater runtime safety and polymorphism.
Protocols
Appenedable- A container that provies an interface ofappend. Safe againstnilvalues. Namely when passing a container with the valuenilinto either the first of second argument toappend, the other value is not change and there is no runtime error.Mappable- A container that provies an interface tomap. Whenmapis called on a container that has anilvalue that container just passes through with out the mapping function being called, and this helps prevent runtime errors.Sequenceable- A container that provides an interface ofnext. This allows the chaining of computations.Unwrappable- A container that provides an interface tosafeandunsafeunwrapping of inner value. Safe will need a default in case ofnilvalue of container, helping prevent runtime errors. Unsafe will just return the value of the container regardless of anilvalue potentially causing runtime errors
Since these are protocols, and highly decoupled, a developer can implement them as needed on their own structs.
Installation
If available in Hex, the package can be installed
by adding containers to your list of dependencies in mix.exs:
def deps do
[{:containers, "~> 0.1.0"}]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/containers.