description | Haskell-style do-notation for Ruby |
owner | aanand.prasad@gmail.com |
last change | Fri, 15 Feb 2008 11:38:45 +0000 (15 11:38 +0000) |
URL | git://repo.or.cz/ruby-do-notation.git |
https://repo.or.cz/ruby-do-notation.git | |
push URL | ssh://repo.or.cz/ruby-do-notation.git |
https://repo.or.cz/ruby-do-notation.git (learn more) | |
bundle info | ruby-do-notation.git downloadable bundles |
content tags |
Example:
class Array
extend Monad
def self.unit x
[x]
end
def bind &f
map(&f).inject([]){ |a,b| a+b }
end
end
Array.run do
x <- ['A', 'a']
y <- ['B', 'b']
unit(x+y)
end
# => ["AB", "Ab", "aB", "ab"]
Its biggest failing, and I don't see a way out, is that you don't get lexical scope. ParseTree is wonderful, but it can't work miracles.
You can work around it, though, by passing in stuff from the outside as arguments to `run', and specifying those arguments on the block you pass in as well.
For more examples, see the test suite.
By Aanand Prasad (aanand.prasad@gmail.com)
2008-02-15 | Aanand Prasad | Simplified Maybemaster | commitcommitdifftreesnapshot (tar.gz zip) |
2008-02-04 | Aanand Prasad | Tweaked spec syntax | commitcommitdifftreesnapshot (tar.gz zip) |
2008-02-04 | Aanand Prasad | Added default rake task | commitcommitdifftreesnapshot (tar.gz zip) |
2008-02-04 | Aanand Prasad | Tweaked README | commitcommitdifftreesnapshot (tar.gz zip) |
2008-02-04 | Aanand Prasad | Removed .tmproj | commitcommitdifftreesnapshot (tar.gz zip) |
2008-01-14 | Aanand Prasad | Now uses arrows!! | commitcommitdifftreesnapshot (tar.gz zip) |
2008-01-12 | Aanand Prasad | RSpec-ified | commitcommitdifftreesnapshot (tar.gz zip) |
2008-01-12 | Aanand Prasad | Initial commit | commitcommitdifftreesnapshot (tar.gz zip) |
16 years ago | master | logtree |