title: Create ToJSON instance for persistent Entity
body: <p>I'm trying to use the new <code>selectRep</code> function from Yesod 1.2, but I'm having trouble getting json responses to work. </p>
  
  <pre><code>instance ToJSON (Entity Feed) where
      toJSON (Entity uid (Feed url lastUpdated)) = object 
          [ "id" .= uid
          , "url" .= url
          , "lastUpdated" .= lastUpdated
          ]
  
  getFeedByIdR :: FeedId -&gt; Handler TypedContent
  getFeedByIdR feedId = do
      feed &lt;- runDB $ get404 feedId
      selectRep $ do
          provideRep $ return $ toJSON (Entity feedId feed)
  </code></pre>
  
  <p>The error I get from the above code is</p>
  
  <pre><code>Handler/Feed.hs:23:31:
      Overlapping instances for ToJSON (Entity Feed)
        arising from a use of `toJSON'
      Matching instances:
        instance ToJSON e =&gt; ToJSON (Entity e)
          -- Defined in `persistent-1.2.0.1:Database.Persist.Class.PersistEntity'
        instance ToJSON (Entity Feed) -- Defined at Handler/Feed.hs:5:10
      In the second argument of `($)', namely
        `toJSON (Entity feedId feed)'
      In the second argument of `($)', namely
        `return $ toJSON (Entity feedId feed)'
      In a stmt of a 'do' block:
        provideRep $ return $ toJSON (Entity feedId feed)
  </code></pre>
  
  <p>It seems that persistent does indeed provide an instance for <code>ToJSON (Entity e)</code> <a href="http://hackage.haskell.org/packages/archive/persistent/1.2.0.1/doc/html/src/Database-Persist-Class-PersistEntity.html" rel="nofollow">here</a>, but can I use my <code>ToJSON (Entity Feed)</code> somehow?</p>