title: What is the Scala type-programming analogy for the `this` keyword?
body: <p>I'm trying to work my way into understanding type-programming in Scala, and I've found that most of what one needs to know about type programming has an analogous counterpart in value programming as is reflected in <a href="https://stackoverflow.com/questions/4415511/scala-type-programming-resources#answer-4443972">the type-level programming wiki page</a>.  However, I've not found the analogy for the <code>this</code> key word or self-types.  I suspect maybe it doesn't make sense to expect such a thing, but I thought I would ask.  </p>
  
  <p>For instance, I can write the following to represent Booleans as values at run time:</p>
  
  <pre class="lang-scala prettyprint-override"><code>sealed trait BoolVal {
    def not:BoolVal
    def or(that:BoolVal):BoolVal
    def and(that:BoolVal) =
      (this.not or that.not).not
    def imp(that:BoolVal) =
      this.not or that
  }
  case object TrueVal extends BoolVal {
    override val not = FalseVal
    override def or(that:BoolVal) = TrueVal
  }
  case object FalseVal extends BoolVal {
    override val not = TrueVal
    override def or(that:BoolVal) = that
  }
  </code></pre>
  
  <p>Here my <code>and</code> and <code>imp</code> are able to take advantage of the fact it doesn't matter if I am a false object or a true object to be defined correctly.  My <code>TrueVal</code> and <code>FalseVal</code> objects can inherit the same code.</p>
  
  <p>I can make the analogous type-level programming constructs, but I don't understand how to define <code>And</code> and <code>Imp</code> in my base trait.</p>
  
  <pre class="lang-scala prettyprint-override"><code>sealed trait BoolType {
    type Not &lt;: BoolType
    type Or[That &lt;: BoolType] &lt;: BoolType
    type And[That &lt;: BoolType] = ???
    type Imp[That &lt;: BoolType] = ???
  }
  sealed trait TrueType extends BoolType {
    override type Not = FalseType
    override type Or[That &lt;: BoolType] = TrueType
  }
  sealed trait FalseType extends BoolType {
    override type Not = TrueType
    override type Or[That &lt;: BoolType] = That
  }
  </code></pre>
  
  <p>I can see where perhaps it doesn't make sense that my types inherit types, but the certainly inherit abstract types.  Is there a way to define <code>And</code> and <code>Impl</code> in my <code>BoolType</code>, or do I have to define each in the respective <code>TrueType</code> and <code>FalseType</code> traits?</p>