Skip to content

Instantly share code, notes, and snippets.

@aristidb
Created August 12, 2012 15:24
Show Gist options
  • Save aristidb/3332273 to your computer and use it in GitHub Desktop.
Save aristidb/3332273 to your computer and use it in GitHub Desktop.
module Git where
import Data.ByteString
import Data.Time
import qualified Data.Map as M
-- | Objects that are stored in the git storage by SHA1. Just a dummy class in this demonstration.
class Storable a
newtype Object = Object { objectData :: ByteString }
instance Storable Object
type FileName = ByteString
type BranchName = ByteString
type Author = ByteString
newtype Tree = Tree (M.Map FileName Object)
instance Storable Tree
data Commit = Commit { commitAuthor :: Author
, commitDate :: UTCTime
, commitParents :: [Commit]
, commitTree :: Tree
}
instance Storable Commit
data Repo = Repo { repoIndex :: Tree -- also known as Staging Area
, repoBranches :: M.Map BranchName Commit
, repoStorage :: () -- dummy for the big git storage
}
instance Storable Repo
-- this model completely ignores packed files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment