Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

a simple Category Theory lib for Ruby

Resources

You can’t perform that action at this time.