type ModuleName = String type Version = String type ModuleId = Int type UserName = String type Timestamp = Int type Module = (ModuleId, ModuleName, Version) type Dependency = (ModuleId, ModuleId) type Usage = (ModuleId, UserName, Timestamp) type Database = ([Module], [Dependency], [Usage]) -- Gettery getModuleId :: Module -> ModuleId getModuleId = undefined getModuleName :: Module -> ModuleName getModuleName = undefined getVersion :: Module -> Version getVersion = undefined getUsageMId :: Usage -> ModuleId getUsageMId = undefined getTimestamp :: Usage -> Timestamp getTimestamp = undefined getUser :: Usage -> UserName getUser = undefined -- Funkce pracující s databází moduleInfo :: ModuleId -> [Module] -> (ModuleName, Version) moduleInfo = undefined moduleId :: ModuleName -> Version -> [Module] -> ModuleId moduleId = undefined versionsOf :: ModuleName -> [Module] -> [(ModuleId, Version)] versionsOf = undefined lastUsedModule :: [Usage] -> ModuleId lastUsedModule = undefined lastUserOf :: ModuleId -> [Usage] -> UserName lastUserOf = undefined insertUsage :: ModuleId -> UserName -> Timestamp -> [Usage] -> [Usage] insertUsage = undefined dependenciesOf :: ModuleId -> [Dependency] -> [ModuleId] dependenciesOf = undefined dependingOn :: ModuleId -> [Dependency] -> [ModuleId] dependingOn = undefined activeSince :: Timestamp -> Database -> [ModuleId] activeSince = undefined purgeModule :: ModuleId -> Database -> Database purgeModule = undefined ------------------------------------------------------------------------------- -- S A M P L E D A T A B A S E -- ------------------------------------------------------------------------------- testDB :: Database testDB = (testModules, testDependencies, testUsage) testModules :: [Module] testModules = [ (1, "ghc", "9.0.1"), (2, "xmobar", "0.35.1"), (3, "ghc", "8.4.3") , (42, "gcc", "10.3.0"), (66, "git", "2.25.1"), (100, "libc", "2.31") , (5, "perl", "5.24") ] testDependencies :: [Dependency] testDependencies = [ (2, 1), (100, 42), (66, 42), (66, 5) ] testUsage :: [Usage] testUsage = [ (1, "Simon Marlow", 1631009291), (5, "Larry Wall", 1464048000) , (2, "Gary Fuchs", 1580443221), (3, "Linus O'Reilly", 1493401234) , (5, "Garry Fuchs", 1323491235) ]