Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mangrove

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mangrove

  • 0.31.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Mangrove

Mangrove is a Ruby Gem designed to be the definitive toolkit for leveraging Sorbet's type system in Ruby applications. It's designed to offer a robust, statically-typed experience, focusing on solid types, a functional programming style, and an interface-driven approach.

  • Documentation
  • Coverage

Features

  • Option Type
  • Result Type
  • Enums with inner types (ADTs)

Installation

bundle add mangrove

Usage

Documentation is available here. For more concrete examples, see spec/**/**_spec.rb.

Mangrove::Result[OkType, ErrType]
Mangrove::Result::Ok[OkType]
Mangrove::Result::Err[ErrType]
Mangrove::Option[InnerType]
Mangrove::Option::Some[InnerType]
Mangrove::Option::None[InnerType]

my_ok = Result::Ok.new("my value")
my_err = Result::Err.new("my err")
my_some = Option::Some.new(1234)
my_none = Option::None.new

##############################

response = MyClient
  .new
  .and_then { |client| client.get_response() }
  .and_then { |response| response.body }

case response
when Mangrove::Result::Ok
  puts response.ok_inner
when Mangrove::Result::Err
  puts response.err_inner
end

##############################

class MyEnum
  extend Mangrove::Enum

  variants do
    variant VariantWithInteger, Integer
    variant VariantWithString, String
    variant VariantWithException, Exception
    variant VariantWithTuple, [Integer, String]
    variant VariantWithShape, { name: String, age: Integer }
  end
end

Commands for Development

git config core.hooksPath hooks
bundle install
bundle exec tapioca init
bundle exec tapioca gems -w `nproc`
bundle exec tapioca dsl -w `nproc`
bundle exec tapioca check-shims
bundle exec tapioca init
bundle exec rspec -f d
bundle exec rubocop -DESP
bundle exec srb typecheck
bundle exec spoom srb tc
bundle exec ordinare --check
bundle exec ruboclean --verify
bundle exec yardoc -o docs/ --plugin yard-sorbet
bundle exec yard server --reload --plugin yard-sorbet
rake build
rake release

FAQs

Package last updated on 11 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc