title: A way to declare a constant value in a type class
body: <p>I want to declare a typeclass that has some implemented functions which utilize an unimplemented constant value (<code>table</code>):</p>
  
  <pre><code>class FromRow a =&gt; StdQueries a where
    table :: String
    byId :: Int -&gt; QueryM (Maybe a)
    byId = fmap listToMaybe . queryM sql . Only
      where sql = read $ "SELECT * FROM " ++ table ++ " WHERE id = ?"
  </code></pre>
  
  <p>The idea is simple: I want to get the <code>byId</code> (and other similar functions) available by instantiating this typeclass by specifying just the <code>table</code>:</p>
  
  <pre><code>instance StdQueries SomeType where
    table = "the_constant_value_for_this_type"
  </code></pre>
  
  <p>But the compiler keeps complaining with the following message:</p>
  
  <pre><code>The class method `table'
  mentions none of the type variables of the class StdQueries a
  When checking the class method: table :: String
  In the class declaration for `StdQueries'
  </code></pre>
  
  <p>Are there any solutions to that kind of a problem? Can tricking with <code>newtype</code> help or anything like that?</p>