gameServer/RoomsAndClients.hs
changeset 3656 c74a4a407146
parent 3654 18189fbc7530
child 3741 73246d25dfe1
equal deleted inserted replaced
3655:1ae653467897 3656:c74a4a407146
    20     client'sM,
    20     client'sM,
    21     room'sM,
    21     room'sM,
    22     allClientsM,
    22     allClientsM,
    23     clientsM,
    23     clientsM,
    24     roomClientsM,
    24     roomClientsM,
       
    25     roomClientsIndicesM,
    25     withRoomsAndClients,
    26     withRoomsAndClients,
    26     allRooms,
    27     allRooms,
    27     allClients,
    28     allClients,
    28     clientRoom,
    29     clientRoom,
    29     showRooms,
    30     showRooms,
   151 allClientsM (MRoomsAndClients (_, clients)) = liftM (map ClientIndex) $ indicesM clients
   152 allClientsM (MRoomsAndClients (_, clients)) = liftM (map ClientIndex) $ indicesM clients
   152 
   153 
   153 clientsM :: MRoomsAndClients r c -> IO [c]
   154 clientsM :: MRoomsAndClients r c -> IO [c]
   154 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
   155 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
   155 
   156 
       
   157 roomClientsIndicesM :: MRoomsAndClients r c -> RoomIndex -> IO [ClientIndex]
       
   158 roomClientsIndicesM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri)
       
   159 
   156 roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
   160 roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
   157 roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)
   161 roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)
   158 
   162 
   159 withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
   163 withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
   160 withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =
   164 withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =