Short Notes
June 4th, 2024

Preparing for Ruby inline type signatures

There is a gem called rbs-inline that is exploring the idea of putting RBS inline in the source code instead of separate files.

Andrey Eremin shared this first, and I just wanted to share it further with some extra screenshots. 

Here is an example from the gem repo (syntax is experimental):

Code sample showing how RBS inline looks like
Code sample from RBS inline gem

The most important part is in the description of this gem, where it seems the plan is to experiment with inline RBS and then merge it to the RBS gem so we can have direct support for inline type signatures instead of only supporting separated files.

Screenshot of RBS inline gem announcing the plan to merge it to RBS
RBS inline gem stating the plan is to merge this to RBS

Using Sorbet for a while, I started to appreciate the following idea: 

If I need type signatures, I would like to have them in the same file with code instead of separated files. This makes it easier to develop a habit of writing and maintain the signatures.