Skip to content
Snippets Groups Projects
Commit 907c7138 authored by Vincent Hanquez's avatar Vincent Hanquez
Browse files

improve types (more strictness, newtype instead of data)

parent 74e435a6
No related branches found
No related tags found
No related merge requests found
...@@ -69,8 +69,8 @@ data ObjectType = ...@@ -69,8 +69,8 @@ data ObjectType =
-- | Git time is number of seconds since unix epoch in the UTC zone with -- | Git time is number of seconds since unix epoch in the UTC zone with
-- the current timezone associated -- the current timezone associated
data GitTime = GitTime data GitTime = GitTime
{ gitTimeUTC :: Elapsed { gitTimeUTC :: !Elapsed
, gitTimeTimezone :: TimezoneOffset , gitTimeTimezone :: !TimezoneOffset
} deriving (Eq) } deriving (Eq)
instance Timeable GitTime where instance Timeable GitTime where
...@@ -177,46 +177,46 @@ type TreeEnt hash = (ModePerm,EntName,Ref hash) ...@@ -177,46 +177,46 @@ type TreeEnt hash = (ModePerm,EntName,Ref hash)
-- FIXME: should be a string, but I don't know if the data is stored -- FIXME: should be a string, but I don't know if the data is stored
-- consistantly in one encoding (UTF8) -- consistantly in one encoding (UTF8)
data Person = Person data Person = Person
{ personName :: ByteString { personName :: !ByteString
, personEmail :: ByteString , personEmail :: !ByteString
, personTime :: GitTime , personTime :: !GitTime
} deriving (Show,Eq) } deriving (Show,Eq)
-- | Represent a root tree with zero to many tree entries. -- | Represent a root tree with zero to many tree entries.
data Tree hash = Tree { treeGetEnts :: [TreeEnt hash] } deriving (Show,Eq) newtype Tree hash = Tree { treeGetEnts :: [TreeEnt hash] } deriving (Show,Eq)
-- | Represent a binary blob. -- | Represent a binary blob.
data Blob hash = Blob { blobGetContent :: L.ByteString } deriving (Show,Eq) newtype Blob hash = Blob { blobGetContent :: L.ByteString } deriving (Show,Eq)
-- | Represent a commit object. -- | Represent a commit object.
data Commit hash = Commit data Commit hash = Commit
{ commitTreeish :: Ref hash { commitTreeish :: !(Ref hash)
, commitParents :: [Ref hash] , commitParents :: [Ref hash]
, commitAuthor :: Person , commitAuthor :: !Person
, commitCommitter :: Person , commitCommitter :: !Person
, commitEncoding :: Maybe ByteString , commitEncoding :: Maybe ByteString
, commitExtras :: [CommitExtra] , commitExtras :: [CommitExtra]
, commitMessage :: ByteString , commitMessage :: !ByteString
} deriving (Show,Eq) } deriving (Show,Eq)
data CommitExtra = CommitExtra data CommitExtra = CommitExtra
{ commitExtraKey :: ByteString { commitExtraKey :: !ByteString
, commitExtraValue :: ByteString , commitExtraValue :: !ByteString
} deriving (Show,Eq) } deriving (Show,Eq)
-- | Represent a signed tag. -- | Represent a signed tag.
data Tag hash = Tag data Tag hash = Tag
{ tagRef :: Ref hash { tagRef :: !(Ref hash)
, tagObjectType :: ObjectType , tagObjectType :: !ObjectType
, tagBlob :: ByteString , tagBlob :: !ByteString
, tagName :: Person , tagName :: !Person
, tagS :: ByteString , tagS :: !ByteString
} deriving (Show,Eq) } deriving (Show,Eq)
-- | Delta pointing to an offset. -- | Delta pointing to an offset.
data DeltaOfs hash = DeltaOfs Word64 Delta data DeltaOfs hash = DeltaOfs !Word64 !Delta
deriving (Show,Eq) deriving (Show,Eq)
-- | Delta pointing to a ref. -- | Delta pointing to a ref.
data DeltaRef hash = DeltaRef (Ref hash) Delta data DeltaRef hash = DeltaRef !(Ref hash) !Delta
deriving (Show,Eq) deriving (Show,Eq)
...@@ -27,6 +27,7 @@ extra-source-files: tests/*.hs ...@@ -27,6 +27,7 @@ extra-source-files: tests/*.hs
Library Library
Build-Depends: base >= 4 && < 5 Build-Depends: base >= 4 && < 5
, basement
, bytestring >= 0.9 , bytestring >= 0.9
, byteable , byteable
, containers , containers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment