title: How to use generic protocol as a variable type
body: <p>Let's say I have a protocol :</p>
  
  <pre><code>public protocol Printable {
      typealias T
      func Print(val:T)
  }
  </code></pre>
  
  <p>And here is the implementation </p>
  
  <pre><code>class Printer&lt;T&gt; : Printable {
  
      func Print(val: T) {
          println(val)
      }
  }
  </code></pre>
  
  <p>My expectation was that I must be able to use <code>Printable</code> variable to print values like this :</p>
  
  <pre><code>let p:Printable = Printer&lt;Int&gt;()
  p.Print(67)
  </code></pre>
  
  <p>Compiler is complaining with this error : </p>
  
  <blockquote>
    <p>"protocol 'Printable' can only be used as a generic constraint because
    it has Self or associated type requirements"</p>
  </blockquote>
  
  <p>Am I doing something wrong ? Anyway to fix this ?</p>
  
  <pre><code>**EDIT :** Adding similar code that works in C#
  
  public interface IPrintable&lt;T&gt; 
  {
      void Print(T val);
  }
  
  public class Printer&lt;T&gt; : IPrintable&lt;T&gt;
  {
     public void Print(T val)
     {
        Console.WriteLine(val);
     }
  }
  
  
  //.... inside Main
  .....
  IPrintable&lt;int&gt; p = new Printer&lt;int&gt;();
  p.Print(67)
  </code></pre>
  
  <p>EDIT 2: Real world example of what I want. Note that this will not compile, but presents what I want to achieve.</p>
  
  <pre><code>protocol Printable 
  {
     func Print()
  }
  
  protocol CollectionType&lt;T where T:Printable&gt; : SequenceType 
  {
     .....
     /// here goes implementation
     ..... 
  }
  
  public class Collection&lt;T where T:Printable&gt; : CollectionType&lt;T&gt;
  {
      ......
  }
  
  let col:CollectionType&lt;Int&gt; = SomeFunctiionThatReturnsIntCollection()
  for item in col {
     item.Print()
  }
  </code></pre>