title: Understanding type equality in function signature
body: <p>In GPipe there is a <a href="https://hackage.haskell.org/package/GPipe-2.2.4/docs/Graphics-GPipe-Texture.html#v:writeTexture2D" rel="nofollow noreferrer">function</a> for writing to texture:</p>
  
  <pre><code>writeTexture2D :: forall ctx b c h w os f m. (ContextHandler ctx, MonadIO m, BufferFormat b, ColorSampleable c, BufferColor (Color c (ColorElement c)) h ~ b, h ~ HostFormat b) =&gt; Texture2D os (Format c) -&gt; Level -&gt; StartPos2 -&gt; Size2 -&gt; [h] -&gt; ContextT ctx os m () 
  </code></pre>
  
  <p>I have a problem understanding part of the signature where type equality is used. There is a <a href="http://tobbebex.blogspot.com/2015/10/gpu-programming-in-haskell-using-gpipe_21.html" rel="nofollow noreferrer">tutorial</a> that sort of talks about it, but does not go into detail explaining what I assume is obvious.</p>
  
  <pre><code>BufferColor (Color c (ColorElement c)) h ~ b, h ~ HostFormat b
  </code></pre>
  
  <p>So what I know:</p>
  
  <ul>
  <li>there is an instance of <code>BufferFormat</code> for <code>b</code></li>
  <li><code>BufferFormat</code> class has an associated type <code>HostFormat</code></li>
  <li><code>h ~ HostFormat b</code> tells me that <code>h</code> must be that <code>HostFormat</code> for a given <code>b</code> ?</li>
  <li><code>h ~ b</code> this tells me that h and b must be the same type ?</li>
  </ul>
  
  <p>But when I look at the <a href="https://hackage.haskell.org/package/GPipe-2.2.4/docs/Graphics-GPipe-Buffer.html#t:BufferFormat" rel="nofollow noreferrer">instances</a> of <code>BufferFormat b</code> I don't think there is any such instance that would have <code>b</code> equal to its own<code>HostFormat b</code> ? Where am I making a mistake?</p>