Sorbet support in dry-monads

I’ve been experimenting with adding Sorbet support to Dry::Monads::Result and Dry::Monads::Maybe. It works well, and allows for type declarations like:

sig { params(html: Nokogiri::HTML::DocumentFragment).returns(Dry::Monads::Result[OptimisationError, Nokogiri::HTML::DocumentFragment]) }
def optimise(html:)

So far I have a dry-monads.rbi file and some code which monkey-patches the those two classes to support the generics syntax. I’m not intimately familiar with Sorbet and may not have written idiomatic code for it.

What would be the best way to get this functionality incorporated into dry-monads proper?

1 Like

I would wrap is an extension that monkey patches required classes similar to how the json extension we have now. This way people can opt-in if needed. Keep in mind, I have zero experience in Sorbet.