Automation of entity reading in yesod
I would experiment with something like the following:

import Data.Typeable

withEntitySql
  :: ( PersistEntityBackend a ~ SqlBackend
     , ToBackendKey SqlBackend a
     , Typeable a )
  =&gt; Int64
  -&gt; (Entity a -&gt; ExceptT Text (HandlerT App IO) b)
  -&gt; ExceptT Text (HandlerT App IO) b
withEntitySql key f = withEntity (show $ typeRep (Proxy :: Proxy a)) (toSqlKey key) f