That's interesting. If you look through the darcs history, you'll
see that at one point we did try using typeclasses. There was a FileStore
type class, and a SearchableFileStore type class, and instances for
git, darcs, and so on. We abandoned this, if I remember correctly,
because it made things much more difficult for the calling program. For
example, Gitit's state looks like this:
data AppState = AppState {
sessions :: Sessions SessionData,
users :: M.Map String User,
config :: Config,
filestore :: FileStore,
mimeMap :: M.Map String String,
cache :: Cache,
template :: T.StringTemplate String,
jsMath :: Bool,
plugins :: [Plugin]
}
filestore is of type FileStore and can be either a git or a darcs
filestore.
, filestore = case repository conf of
Git fs -> gitFileStore fs
Darcs fs -> darcsFileStore fs
But how would this go if FileStore were a type class, not a type?
, filestore = case repository conf of
Git fs -> GitFileStore fs
Darcs fs -> DarcsFileStore fs
But this doesn't typecheck, because GitFileStore fs and
DarcsFileStore fs have different types...
John