0.0
The project is in a healthy, maintained state
Simple monads without DRY dependencies
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Simple Monads

Build Status Gem Gem Version

If you just need simple monads and nothing more

Installation

gem 'simple_monads'

And then execute:

bundle install

Or install it yourself as:

gem install simple_monads

Require if necessary:

require 'simple_monads'

Usage

Simple example of use:

class SomeClass
  include SimpleMonads

  def return_failure
    Failure({ error: 'text' })
  end

  def return_success
    Success(5)
  end
end

Then using this object you can check and use monads:

Failure examples

object = SomeClass.new

result = object.return_failure

result.failure? # true

result.success? # false

result.failure # { error: 'text' }

result.success_or(19.32) # 19.32

Success examples

object = SomeClass.new

result = object.return_success

result.failure? # false

result.success? # true

result.success # 5

result.success_or(19.32) # 5

Contribution

If you would like to contribute to the development, submit a pull request with your changes. We welcome any contributions that improve the service. You can also view the current project board here. You can also contribute by reporting bugs or suggesting new features. Please use the GitHub issues for that.