title: Haskell Servant: How to prefix routes when using generics?
body: <p>I'm using Servant generic, and have a datatype for my routes:</p>
  <pre><code>data Routes route = Routes
    { getLiveness :: route :- GetLiveness,
      getReadiness :: route :- GetReadiness,
  
      getAuthVerifyEmailToken :: route :- GetAuthVerifyEmailToken,
      postAuthEmail :: route :- PostAuthEmail,
      ...
    }
    deriving (Generic)
  
  type BackendPrefix = &quot;backend&quot;
  
  type AuthPrefix = &quot;auth&quot;
  
  type GetLiveness = BackendPrefix :&gt; &quot;liveness&quot; :&gt; Get '[JSON] Text
  
  type GetReadiness = BackendPrefix :&gt; &quot;readiness&quot; :&gt; Get '[JSON] Text
  
  type GetAuthVerifyEmailToken = AuthPrefix :&gt; &quot;verify&quot; :&gt; &quot;email&quot; :&gt; Capture &quot;token&quot; JWT :&gt; RedirectResponse '[PlainText] NoContent
  
  type PostAuthEmail = AuthPrefix :&gt; &quot;email&quot; :&gt; ReqBody '[JSON] AuthEmailRequest :&gt; PostNoContent
  </code></pre>
  <p>The first two use the same prefix <code>&quot;backend&quot;</code>, and all other's have an <code>&quot;auth&quot;</code> prefix.</p>
  <p>However, I now want to change the <code>&quot;auth</code>&quot; prefix to &quot;backend/auth&quot;. So I tried chaging:</p>
  <p><code>type AuthPrefix = BackendPrefix :&gt; &quot;auth&quot;</code></p>
  <p>This results in an error</p>
  <pre><code>&gt;     • Expected a type, but
  &gt;       ‘&quot;auth&quot;’ has kind
  &gt;       ‘ghc-prim-0.6.1:GHC.Types.Symbol’
  &gt;     • In the second argument of ‘(:&gt;)’, namely ‘&quot;auth&quot;’
  &gt;       In the type ‘BackendPrefix :&gt; &quot;auth&quot;’
  &gt;       In the type declaration for ‘AuthPrefix’
  &gt;    |
  &gt; 34 | type AuthPrefix = BackendPrefix :&gt; &quot;auth&quot;
  &gt;    |          
  </code></pre>
  <p>So I googled and found you can do <a href="https://stackoverflow.com/questions/36243779/how-to-add-a-prefix-to-all-the-end-points-in-servant">this</a> when not using generic you can do:</p>
  <pre><code>type APIv1 = &quot;api&quot; :&gt; &quot;v1&quot; :&gt; API
  </code></pre>
  <p>But I couldn't figure out how to do this with generics.</p>
  <p>I guess that leaves two questions:</p>
  <ol>
  <li>What does the above error mean, and can I use something like <code>type AuthPrefix = BackendPrefix :&gt; &quot;auth&quot;</code> to create a more complex prefix?</li>
  <li>Is there a way to prefix some routes with one prefix, and the other routes with a different prefix, when using generics in Servant?</li>
  </ol>