FileStore Feels OO (not FP)

2 views
Skip to first unread message

thomas hartman

unread,
Mar 17, 2009, 10:54:34 PM3/17/09
to gitit-discuss
I had some musings on the FileStore library here:

http://blog.patch-tag.com/2009/03/18/fields-whose-type-is-an-impure-function-are-evil-because-i-say-so/

The main conclusion is that this would seem nicer if it took advantage
of typeclassing somehow so that filestores for darcs, git, etc would
be different types.

Matthew Elder

unread,
Mar 17, 2009, 11:07:31 PM3/17/09
to gitit-...@googlegroups.com
Yay! Go blog posts ;)
--
Sent from my mobile device

Need somewhere to put your code? http://patch-tag.com
Want to build a webapp? http://happstack.com

Matthew Elder

unread,
Mar 17, 2009, 11:11:29 PM3/17/09
to gitit-...@googlegroups.com
Yay! Go blog posts ;)

On 3/17/09, thomas hartman <thomash...@googlemail.com> wrote:
>

John MacFarlane

unread,
Mar 17, 2009, 11:33:39 PM3/17/09
to gitit-...@googlegroups.com
+++ thomas hartman [Mar 17 09 19:54 ]:

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

Thomas Hartman

unread,
Mar 18, 2009, 3:01:18 PM3/18/09
to gitit-...@googlegroups.com
After playing with this for a while, I think I agree... for now :)
--
Thomas Hartman

Need somewhere to host your code? patch-tag.com
Want to build a webapp? happstack.com
Reply all
Reply to author
Forward
0 new messages