|
1 {- |
|
2 * Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation; version 2 of the License |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
17 \-} |
|
18 |
1 {-# LANGUAGE BangPatterns, GeneralizedNewtypeDeriving #-} |
19 {-# LANGUAGE BangPatterns, GeneralizedNewtypeDeriving #-} |
2 |
20 |
3 module RoomsAndClients( |
21 module RoomsAndClients( |
4 RoomIndex(), |
22 RoomIndex(), |
5 ClientIndex(), |
23 ClientIndex(), |
155 room'sM (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = liftM (f . room') (rooms `readElem` ri) |
175 room'sM (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = liftM (f . room') (rooms `readElem` ri) |
156 |
176 |
157 allClientsM :: MRoomsAndClients r c -> IO [ClientIndex] |
177 allClientsM :: MRoomsAndClients r c -> IO [ClientIndex] |
158 allClientsM (MRoomsAndClients (_, clients)) = liftM (map ClientIndex) $ indicesM clients |
178 allClientsM (MRoomsAndClients (_, clients)) = liftM (map ClientIndex) $ indicesM clients |
159 |
179 |
|
180 allRoomsM :: MRoomsAndClients r c -> IO [RoomIndex] |
|
181 allRoomsM (MRoomsAndClients (rooms, _)) = liftM (map RoomIndex) $ indicesM rooms |
|
182 |
160 clientsM :: MRoomsAndClients r c -> IO [c] |
183 clientsM :: MRoomsAndClients r c -> IO [c] |
161 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (liftM client' . readElem clients) |
184 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (liftM client' . readElem clients) |
|
185 |
|
186 roomsM :: MRoomsAndClients r c -> IO [r] |
|
187 roomsM (MRoomsAndClients (rooms, _)) = indicesM rooms >>= mapM (liftM room' . readElem rooms) |
162 |
188 |
163 roomClientsIndicesM :: MRoomsAndClients r c -> RoomIndex -> IO [ClientIndex] |
189 roomClientsIndicesM :: MRoomsAndClients r c -> RoomIndex -> IO [ClientIndex] |
164 roomClientsIndicesM (MRoomsAndClients (rooms, _)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) |
190 roomClientsIndicesM (MRoomsAndClients (rooms, _)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) |
165 |
191 |
166 roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c] |
192 roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c] |