title: Why does Ruby module inclusion exclude the module's singleton class?
body: <p>When classes are inherited in Ruby the singleton classes are also inherited:</p>
  
  <pre><code>class A
    def self.hello
      puts "hello"
    end
  end
  
  class B &lt; A
  end
  
  B.hello #=&gt; "hello"
  </code></pre>
  
  <p>Yet with modules, this is not the case:</p>
  
  <pre><code>module M
    def self.goodbye
      puts "goodbye"
    end
  end
  
  class A
    include M
  end
  
  A.goodbye #=&gt; NameError
  </code></pre>
  
  <p>To get around this limitation many ppl resort to this ugly hack:</p>
  
  <pre><code>module M
    def self.included(c)
      c.extend ClassMethods
    end
  
    module ClassMethods
      def goodbye
        puts "goodbye"
      end
    end
  end
  </code></pre>
  
  <p>Ok, so my question: is there a theoretical/conceptual reason behind this limitation on modules? or was it just an implementation difficulty?</p>
  
  <p>After looking at the C source code (YARV/MRI) I can identify there is an implementation difficulty (not insurmountable, but one all the same), but is this the sole reason? Are there any other reasons for this limitation?</p>
  
  <p>thanks</p>