README.md in ribimaybe-0.0.11 vs README.md in ribimaybe-0.0.12

- old
+ new

@@ -1,16 +1,16 @@ # Ribimaybe > "Flavouring the ocean with a teaspoon of sugar." [![Gem Version](https://badge.fury.io/rb/ribimaybe.svg)](http://badge.fury.io/rb/ribimaybe) -[![Travis](https://travis-ci.org/unsymbol/ribimaybe.svg?branch=master)](http://travis-ci.org/unsymbol/ribimaybe) +[![Travis](https://travis-ci.org/filib/ribimaybe.svg?branch=master)](http://travis-ci.org/filib/ribimaybe) [![Code Climate](https://codeclimate.com/github/unsymbol/ribimaybe.png)](https://codeclimate.com/github/unsymbol/ribimaybe) ![](maybe.gif) -A tiny Ruby library that provides a Maybe datatype which is a Functor, +A tiny Ruby library that provides a Maybe datatype which is a Functor, Applicative Functor and Monad. ## Installation Add this line to your application's Gemfile: @@ -25,27 +25,27 @@ $ gem install ribimaybe ## Usage -This is a small library and so it doesn't offer lots of creature comforts. The -one escape hatch it does offer is the ability to convert `nil` into `Nothing`. +This is a small library and so it doesn't offer lots of creature comforts. The +one escape hatch it does offer is the ability to convert `nil` into `Nothing`. ``` ruby include Ribimaybe::Maybe Maybe(42) # => Just(42) Maybe(nil) # => Nothing ``` -And that's it, once you have lifted your value into a `Maybe` you can treat it +And that's it, once you have lifted your value into a `Maybe` you can treat it as a `Functor`, `Applicative Functor` or `Monad`. If you want to pull your value out of a `Maybe`, we got you covered too. ``` ruby Just(42).maybe(false) { |x| x == 42 } # => true -Nothing.maybe(false) { |x| x == 42 } # => false +Nothing.maybe(false) { |x| x == 42 } # => false ``` ### Functor [\[info\]](http://learnyouahaskell.com/functors-applicative-functors-and-monoids) ``` ruby @@ -59,17 +59,21 @@ ### Applicative Functor [\[info\]](http://learnyouahaskell.com/functors-applicative-functors-and-monoids) ``` ruby include Ribimaybe::Maybe -# Wrap functions inside functors and apply them to other functors! +# Wrap functions inside functors and apply them to other functors! Just do |x, y| x * y end.apply(pure(42)).apply(pure(42)) # => Just(1764) Just do |x| x * x end.apply(Nothing) # => Nothing + +# We can't define <*> but we can define a different operator with the same +# semantics! +Just { |x, y| x * y } >> pure(42) >> pure(42) # => Just(1764) ``` ### Monad [\[info\]](http://www.learnyouahaskell.com/a-fistful-of-monads) ``` ruby