Build Status Inline docs Deps Status hex.pm version API Docs license

TL;DR

Algae is a collection of common data structures, intended for use with libraries like Witchcraft

Quickstart

Add Algae to your list of dependencies in mix.exs:


def deps do
  [{:algae, "~> 0.12"}]
end

Select Examples

Maybe

import Algae.Maybe

[1,2,3]
|> List.first
|> case do
     nil  -> nothing
     head -> just(head)
   end
#=> %Algae.Maybe.Just{just: 1}

[]
|> List.first
|> case do
     nil  -> nothing
     head -> just(head)
   end
#=> %Algae.Maybe.Nothing{}

Reader

%Algae.Reader{env: 42} |> read
# 42

config =
  %Algae.Reader.new{
    reader: &Map.get/1,
    env: %{
      uri:   "https://api.awesomeservice.com",
      token: "12345"
    }
  }
:uri |> read(config)
#=> "https://api.awesomeservice.com"

elapsed_time =
  %Algae.Reader.new{
    env: %{start_time: 1472717375},
    reader:
      fn %{start_time: start_time} ->
        now = DateTime.now |> DateTime.to_unix
        "#{now - start_time}ms"
      end
  }
run elapsed_time
#=> "42ms"