title: Data.Proxy in servant's public API (why Proxy with ScopedTypeVariables doesn't work)
body: <p>I'm excited about <a href="http://haskell-servant.github.io/" rel="noreferrer">servant</a>, and I'm ok with its internal typelevel magic as long as it doesn't gets in the way, and the only thing that confuses me is its use of a <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Proxy.html" rel="noreferrer">type-proxy</a> in public API. Here's the <a href="https://github.com/haskell-servant/servant/blob/master/servant-server/src/Servant/Server.hs#L109" rel="noreferrer">code</a>:</p>
  
  <pre><code>serve :: HasServer layout =&gt; Proxy layout -&gt; Server layout -&gt; Application
  serve p server = toApplication (runRouter (route p (return (RR (Right server)))))
  </code></pre>
  
  <p>As I understand, type-proxies are fairly simple thing and are needed to carry a type when you don't have a value with that type. So why to pass a proxy carrying layout type when there is already layout type in Server's type parameter? I've tried cloning servant's repo and changing code to this:</p>
  
  <pre><code>{-# LANGUAGE ScopedTypeVariables #-}
  
  serve :: forall layout . HasServer layout =&gt; Server layout -&gt; Application
  serve server = toApplication (runRouter (route p (return (RR (Right server)))))
    where
      p :: Proxy layout
      p  = Proxy
  </code></pre>
  
  <p>And surprisingly to me this fails to compile (telling something about layout type mismatch). But why, shouldn't my local p have the same layout type as server (with ScopedTypeVariables turned on)?</p>