Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattludwigs/containers
Functional container like data structures for better runtime safety and polymorphism
https://github.com/mattludwigs/containers
elixir elixir-lang functional-programming
Last synced: 29 days ago
JSON representation
Functional container like data structures for better runtime safety and polymorphism
- Host: GitHub
- URL: https://github.com/mattludwigs/containers
- Owner: mattludwigs
- Created: 2017-04-13T14:04:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-08-03T03:45:13.000Z (over 4 years ago)
- Last Synced: 2024-11-06T06:15:58.001Z (about 2 months ago)
- Topics: elixir, elixir-lang, functional-programming
- Language: Elixir
- Homepage: https://hex.pm/packages/containers
- Size: 46.9 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Containers
Containers are functional like data structures that help provide greater runtime safety and polymorphism.
This package is dependency free. There are some dev only deps, but the package only relies on Elixir.
## Protocols
* `Appendable` - A container that provides an interface of `append`. Safe against `nil` values.
Namely when passing a container with the value `nil` into either the first of second argument
to `append`, the other value is not change and there is no runtime error.
* `Mappable` - A container that provides an interface to `map`. When `map` is called on a container that
has a `nil` value 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 of `next`. This allows the chaining of computations.
* `Unwrappable` - A container that provides an interface to `safe` and `unsafe` unwrapping of inner value. Safe
will need a default in case of `nil` value of container, helping prevent runtime errors. Unsafe will just return
the value of the container regardless of a `nil` value potentially causing runtime errors
* `Joinable` - A container that has a nested container of the same type, and is able to be join down into
a single representation of the structure.Since these are protocols, and highly decoupled, a developer can implement them as needed on their own structs.
## Installation
The package can be installed by adding `containers` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:containers, "~> 0.7.1"}]
end
```# Note
Until version `1.0.0` assume minor changes (that is the number in the second spot) to reflect breaking changes.