title: What are all the mechanisms used to enable Servant's type-based API?
body: <p>I'm very puzzled by how Servant is able to achieve the magic that it does using typing. The example on the web site already puzzles me greatly:</p>
  
  <pre><code>type MyAPI = "date" :&gt; Get '[JSON] Date
          :&lt;|&gt; "time" :&gt; Capture "tz" Timezone :&gt; Get '[JSON] Time
  </code></pre>
  
  <p>I get the "date", "time", <code>[JSON]</code> and "tz" are type-level literals. They are values that have "become" types. Okay.</p>
  
  <p>I get that <code>:&gt;</code> and <code>:&lt;|&gt;</code> are type operators. Okay.</p>
  
  <p>I don't get how these things, after they've become types, can be extracted back out into values. What's the mechanism to do this?</p>
  
  <p>I also don't get how the first part of this type can get the framework to expect a function of the signature <code>IO Date</code>, or how the second part of this type can get the framework to expect a function of the signature <code>Timezone -&gt; IO Time</code> from me. How does this transformation happen? </p>
  
  <p>And how then can the framework call a function for which it didn't initially know the type?</p>
  
  <p>I'm sure there are a number of GHC extensions and unique features at play here that I'm not familiar with that combine to make this magic happen. </p>
  
  <p>Can someone explain what features are involved here and how they are working together?</p>