gameServer/RoomsAndClients.hs
changeset 3645 c0b3f1bb9316
parent 3566 772a46ef8288
child 3654 18189fbc7530
equal deleted inserted replaced
3644:42c5684289ae 3645:c0b3f1bb9316
    16     clientRoom,
    16     clientRoom,
    17     clientRoomM,
    17     clientRoomM,
    18     client,
    18     client,
    19     room,
    19     room,
    20     client'sM,
    20     client'sM,
       
    21     room'sM,
    21     clientsM,
    22     clientsM,
    22     roomClientsM,
    23     roomClientsM,
    23     withRoomsAndClients,
    24     withRoomsAndClients,
    24     allRooms,
    25     allRooms,
    25     allClients,
    26     allClients,
   140 clientRoomM (MRoomsAndClients (_, clients)) (ClientIndex ci) = liftM clientRoom' (clients `readElem` ci)
   141 clientRoomM (MRoomsAndClients (_, clients)) (ClientIndex ci) = liftM clientRoom' (clients `readElem` ci)
   141 
   142 
   142 client'sM :: MRoomsAndClients r c -> (c -> a) -> ClientIndex -> IO a
   143 client'sM :: MRoomsAndClients r c -> (c -> a) -> ClientIndex -> IO a
   143 client'sM (MRoomsAndClients (_, clients)) f (ClientIndex ci) = liftM (f . client') (clients `readElem` ci)
   144 client'sM (MRoomsAndClients (_, clients)) f (ClientIndex ci) = liftM (f . client') (clients `readElem` ci)
   144 
   145 
       
   146 room'sM :: MRoomsAndClients r c -> (r -> a) -> RoomIndex -> IO a
       
   147 room'sM (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = liftM (f . room') (rooms `readElem` ri)
       
   148 
   145 clientsM :: MRoomsAndClients r c -> IO [c]
   149 clientsM :: MRoomsAndClients r c -> IO [c]
   146 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
   150 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
   147 
   151 
   148 roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
   152 roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
   149 roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)
   153 roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)