GitPedia
witchcrafters

witchcrafters/witchcraft

Monads and other dark magic for Elixir

4 Releases
Latest: 9y ago
Monads (and reorganize)0.5.0-alphaLatestPre-release
expedeexpede·9y ago·September 12, 2016
GitHub

# Monads Finally, monads! Still could use more documentation, but they're here and they work 😄 ``` elixir [1, 2, 3] >>> fn x -> [x + 1] >>> fn y -> [y * x, y * 10, x - 1] end end #=> [2, 20, 0, 6, 30, 1, 12, 40, 2] [1, 2, 3] >>> fn x -> [x + 1] end >>> fn y -> [y * 10, y - 1] end #=> [20, 1, 30, 2, 40, 3] ``` Of course they work on things other than lists. I'll will be moving the ADT-specifc implementations to [Algae](https://github.com/expede/algae), so if you want `Maybe`, `Either`, and friends, please use it in conjunction with that library. # Major Reorganization Still a _bunch_ more to do, but this is already much better. Merging to master, and will continue to tighten stuff up and work through the roadmap.

Applicative Functor0.3.0Pre-release
expedeexpede·10y ago·January 12, 2016
GitHub

📋 Changes

  • `wrap` (i.e.: pure) & `apply` are here!
  • Operator for `apply`: `<<~` and `~>>`
  • Reversed operator arrow direction for consistence with Elixir
  • ie: in Haskell we think about `apply`ping "over" things (`apply [(+1)] [1,2,3]`)
  • In Elixir, we're piping thing _into_ the application (`[1,2,3] ~>> [&(&1 + 1)]`)
  • Can still write in the Haskell order, with reversed operators:
  • Haskell: `(\x y -> x + y) <$> [1,2,3] <*> [4,5,6]`
  • Elixir: `&(&1 + &2) <~ [1,2,3] <<~ [4,5,6]`
  • + 2 more
Functor0.2.0Pre-release
expedeexpede·10y ago·November 8, 2015
GitHub

📋 Changes

  • Only the covariant functor, more varieties will follow
Monoid0.1.0Pre-release
expedeexpede·10y ago·October 29, 2015
GitHub

First draft of the `Monoid` protocol