title: OptionSetType and enums
body: <p>I have an enum named <code>ProgrammingLanguage</code>:</p>
  
  <pre><code>enum ProgrammingLanguage {
    case Swift, Haskell, Scala
  }
  </code></pre>
  
  <p>Now I have a class named <code>Programmer</code> with the following property:</p>
  
  <pre><code>let favouriteLanguages: ProgrammingLanguage = .Swift
  </code></pre>
  
  <p>Seeing how a programmer could have several favourite languages, I'd thought it'd be nice to write something like this:</p>
  
  <pre><code>let favouriteLanguages: ProgrammingLanguage = [.Swift, .Haskell]
  </code></pre>
  
  <p>After a bit of research, I realized that I need to conform to <code>OptionSetType</code>, but in doing so, I've raise the following 3 errors:</p>
  
  <p><strong>ProgrammingLanguage does not conform to</strong></p>
  
  <ol>
  <li><code>SetAlgebraType</code> </li>
  <li><code>OptionSetType</code> </li>
  <li><code>RawRepresentable</code></li>
  </ol>
  
  <p>When I saw the <strong>Raw Representable</strong> error, I immediately thought of associated types for enums. I wanted to be able to print the enum value anyway, so I changed my enum signature to the following:</p>
  
  <pre><code>case ProgrammingLanguage: String, OptionSetType {
    case Swift, Haskell, Scala
  }
  </code></pre>
  
  <p>This silenced 2 of the warnings. But I'm still left with one which is that I don't conform to protocol <code>SetAlgebraType</code>. </p>
  
  <p>After a bit of trial and error, I found out having the associated type of the enum as <code>Int</code> fixed it (which makes sense, since the <code>RawRepresentable</code> protocol requires you to implement an initializer of the signature <code>init(rawValue: Int)</code>). However, I'm unsatisfied with that; I want to be able to get the String representation of the enum easily. </p>
  
  <p>Could someone advise me how I can do this easily, and why <code>OptionSetType</code> requires an <code>Int</code> associated type?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>The following declaration compiles correctly, but errors at runtime:</p>
  
  <pre><code>enum ProgrammingLanguage: Int, OptionSetType {
    case Swift, Scala, Haskell
  }
  
  extension ProgrammingLanguage {
    init(rawValue: Int) {
      self.init(rawValue: rawValue)
    }
  }
  
  let programmingLanguages: ProgrammingLanguage = [.Swift, .Scala]
  </code></pre>