0.01
No commit activity in last 3 years
No release in over 3 years
Haskell-style monad do-notation for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 2.0

Runtime

 Project Readme

Haskell-style monad do-notation for Ruby

Example:

require 'do_notation'

class Array
  include Monad

  def self.unit x
    [x]
  end

  def bind &f
    map(&f).inject([], &:+)
  end
end

Array.run do
  x <- ["first", "second"]
  y <- ["once", "twice"]

  unit("#{x} cousin #{y} removed")
end

The above code returns the array:

["first cousin once removed",
 "first cousin twice removed",
 "second cousin once removed",
 "second cousin twice removed"]

For more examples, see the test suite.

Installation

gem install do_notation

By Aanand Prasad (aanand.prasad@gmail.com)