I am working on a webapp using Happstack and I am writing some code to store my types in MongoDB. I felt like shortening my code some by putting the code into a typeclass so that I could use the same code to read and write to the database for different types. Something like this:
class DatabaseType a where
toDoc :: a -> Document
fromDoc :: Document -> a
saveCollection :: Text
getFromDatabase :: (MonadIO m) => Pipe -> Text -> Value -> m a
getFromDatabase pipe field value = ...
...
Now the problem here is the saveCollection, since it doesn't use any of the type variables GHC won't let it compile, however it is very important to the database functions (like getFromDatabase) so that they know which collection to save to.
Question is, how to have a value in a typeclass that is not bonded by the type variables.