title: How can I specify the polymorphic type of a sub-expression?
body: <p>This compiles:</p>
  
  <pre><code>foo :: (Bounded a,Enum a) =&gt; a -&gt; Int
  foo x = length ([minBound .. x] ++ drop 1 [x .. maxBound])
  </code></pre>
  
  <p>This doesn't compile:</p>
  
  <pre><code>foo :: (Bounded a,Enum a) =&gt; a -&gt; Int
  foo x = length ([minBound .. maxBound] :: [a])
  </code></pre>
  
  <p>I think the second example doesn't compile because the type <code>a</code> in the type signature is not the same as the one in the sub-expression's type signature. How can I make the sub-expression's type refer to the polymorphic type given above?</p>