ruby / ruby/rbs

Better support for singleton types in modules

Open
#1,334 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Ruby
Stars
2.2k
Forks
256
Avg merge
6d 17h
Merged PRs (30d)
37

Description

Motivating example:

module SoftDeletable : ActiveRecord::Base
  module ClassMethods : singleton(ActiveRecord::Base)    # New syntax!
  end
end

Here, the implementation of SoftDeletable would use ActiveRecord::Base methods from included hook:

module SoftDeletable
  included do
    scope :deleted, ...
  end
end
  1. Allow having singleton types in module self type constraints
  2. Let singleton(SoftDeletable) < singleton(ActiveRecord::Base) (but what to do at the module context?)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the motivating RBS module example and the requested module self type constraints. Determine the intended behavior for singleton(SoftDeletable) being a subtype of singleton(ActiveRecord::Base), including the module-context question; done means the syntax and subtyping rules are specified and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.