Kleisli::Contracts
Provides the following Contracts for monads provided by the Kleisli gem:
MaybeOf[SomeType]
EitherOf[LeftType, RightType]
ValidationOf[FailureType, SuccessType]
Installation
Add this line to your application's Gemfile:
gem 'kleisli-contracts'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kleisli-contracts
You can then require and include it in your class as follows:
require 'kleisli/contracts'
class Something
include Kleisli::Contracts
end
This will provide you with all the mixins from the Contracts gem, as well as the Kleisli specific Contracts defined in this one.
Usage
Use of Contracts is well documented here
Use of Maybe and Either are well documented here
Use of Validation is well documented here
Example use can be seen in the tests
Contributing
- Fork it ( https://github.com/[my-github-username]/kleisli-contracts/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request