git-annex/Types/Group.hs

39 lines
749 B
Haskell
Raw Normal View History

{- git-annex repo groups
-
- Copyright 2012, 2019 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Types.Group (
Group(..),
fromGroup,
toGroup,
2012-10-08 19:18:58 +00:00
GroupMap(..),
emptyGroupMap
) where
import Types.UUID
import Utility.FileSystemEncoding
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString as S
newtype Group = Group S.ByteString
deriving (Eq, Ord, Show)
fromGroup :: Group -> String
fromGroup (Group g) = decodeBS g
toGroup :: String -> Group
toGroup = Group . encodeBS
2012-10-02 17:45:30 +00:00
data GroupMap = GroupMap
{ groupsByUUID :: M.Map UUID (S.Set Group)
, uuidsByGroup :: M.Map Group (S.Set UUID)
}
2012-10-08 19:18:58 +00:00
emptyGroupMap :: GroupMap
emptyGroupMap = GroupMap M.empty M.empty