Skip to content
Browse files

Bump version to v0.2.0

  • Loading branch information...
1 parent 5a218d1 commit a42bf7c3c967395405f605c4ff7c83f6ff2fb486 @pzol committed
Showing with 18 additions and 2 deletions.
  1. +11 −0 CHANGELOG.md
  2. +6 −1 README.md
  3. +1 −1 lib/monadic/version.rb
View
11 CHANGELOG.md
@@ -1,5 +1,16 @@
# Changelog
+## v0.2.0 (not released)
+**BREAKING CHANGES**
+
+`Monad#map` does not recognize `Enumerables` automatically anymore. It just maps, as a `Functor`.
+Instead the new `Monad#flat_map` function operates on the underlying value as on `Enumerable`.
+
+`Either#else` allows to exchange the inner value of `Nothing` to an alternative value.
+
+ Either(false == true).else('false was not true') == Failure(false was not true)
+ Success('truth needs no sugar coating').else('all lies') == Success('truth needs no sugar coating')
+
## v0.1.1
`Either()` coerces only `StandardError` to `Failure`, other exceptions higher in the hierarchy are will break the flow.
View
7 README.md
@@ -64,12 +64,17 @@ Map, select:
```ruby
Maybe(123).map { |value| User.find(value) } == Just(someUser) # if user found
Maybe(0).map { |value| User.find(value) } == Nothing # if user not found
-Maybe([1,2]).map { |value| value.to_s } == Just(["1", "2"]) # for all Enumerables
+Maybe([1,2]).map { |value| value.to_s } == Just(["1, 2"]) # for all Enumerables
Maybe('foo').select { |value| value.start_with?('f') } == Just('foo')
Maybe('bar').select { |value| value.start_with?('f') } == Nothing
```
+For `Enumerable` use `#flat_map`:
+```ruby
+Maybe([1, 2]).flat_map {|v| v + 1 } == Just([2, 3])
+```
+
Treat it like an array:
```ruby
View
2 lib/monadic/version.rb
@@ -1,3 +1,3 @@
module Monadic
- VERSION = "0.1.1"
+ VERSION = "0.2.0"
end

0 comments on commit a42bf7c

Please sign in to comment.
Something went wrong with that request. Please try again.