a simple Category Theory lib for Ruby
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
.gitignore
.semver
.yardopts
Gemfile
Gemfile.lock
README.md
Rakefile
bump
ci-docs.sh
ci-publish.sh
circle.yml

README.md

Cats.rb

Cats.rb is a collection of Category Theory libs for Ruby. You'll find it very handy if you familiar with Haskell or scalaz/cats

CircleCI Document Coverage Status License

😹 ➡️ 😼
⬇️ ↘️ ⬇️
🙀 ➡️ 😻

ADT

data.either

Gem Gem Document

install

gem install data.either

How to use

require 'data.either'
Right.new(1).flat_map do |x| 
  if x < 1
    Left.new('meh')
  else
    Right.new(x+1)
  end
end
# => #<Right value=2>

Right.new(1) >> Left.new('oops') >> Right.new(1) # => #<Left value=oops>

more detail on Document

data.maybe

Gem Gem

install

gem install data.maybe

How to use

require 'data.maybe'
Just.new(1).flat_map do |x| 
  if x < 1
    Nothing
  else
    Just.new(x+1)
  end
end
# => #<Just 2>

Maybe.new(1) >> Nothing >> Maybe.new(2) # => #<Nothing>

WIP

control.monad.free

install

gem install control.monad.free

How to use

Roll.new(Just.new(Return.new(1))).flat_map { |x| Roll.new(Right.new(Return.new(x + 1))) }
# Roll.new(Just.new(Roll.new(Right.new(Return.new(2)))))

control.exception

to be continue...

  • data.validate