title: Explicit forall on a type class function
body: <p>Since ghc-8.0 we have a very nice extension called <code>TypeApplications</code>. Which allows us instead of:</p>
  
  <pre><code>λ&gt; show (5 :: Int)
  "5"
  </code></pre>
  
  <p>do so something like that:</p>
  
  <pre><code>λ&gt; :set -XTypeApplications
  λ&gt; show @Int 5
  "5"
  </code></pre>
  
  <p>Which is really cool. It becomes a bit more involved when we add more type variables, but there are rules that can be used to determine the exact order, and they are very well documented:</p>
  
  <pre><code>showFooBar :: (Show a, Show b) =&gt; a -&gt; b -&gt; String
  showFooBar a b = show a ++ " and " ++ show b
  </code></pre>
  
  <p>So in the function above we would first supply <code>a</code> and then <code>b</code>:</p>
  
  <pre><code>λ&gt; showFooBar @Int @Double 3 4
  "3 and 4.0"
  </code></pre>
  
  <p>That's great, but what if I'd like to change the order? No problem there, we can use <code>ExplicitForAll</code> extension (or some other that imply it) to specify it:</p>
  
  <pre><code>{-# LANGUAGE ExplicitForAll #-}
  
  showFooBar :: forall b a . (Show a, Show b) =&gt; a -&gt; b -&gt; String
  showFooBar a b = show a ++ " and " ++ show b
  </code></pre>
  
  <p>And now we reversed the order of types that we are going to apply:</p>
  
  <pre><code>λ&gt; showFooBar @Int @Double 3 4
  "3.0 and 4"
  </code></pre>
  
  <p>The problem is that I can't seem to figure out how to achieve the same affect for functions that are part of a type class. Consider this example:</p>
  
  <pre><code>{-# LANGUAGE MultiParamTypeClasses #-}
  
  class (Show a, Show b) =&gt; FooBar a b where
    fooBarClassFunc :: a -&gt; b -&gt; String
  </code></pre>
  
  <p>I can't put <code>forall</code> on a function now (eg. <code>fooBarClassFunc :: forall a b . a -&gt; b -&gt; ..</code>, cause that changes the meaning of the function and obviously does not compile.</p>
  
  <p>So, the question is, how do you change the order of type variables for the purpose of <code>TypeApplication</code> inside the type class methods?</p>
  
  <p><em>Edit</em></p>
  
  <p>Just in case, I have tried <code>InstanceSigs</code> extension, and it completely ignores the order of <code>forall</code> type variables as far as <code>TypeApplications</code> are concerned, which is a good thing, otherwise we would end up with behavior that is determined by the instance, rather than the class.</p>