{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
module PrioritySync.Internal.RoomGroup
    (RoomGroup(..))
    where

import PrioritySync.Internal.UserData
import PrioritySync.Internal.RoomCore

class RoomGroup m where
    roomsOf :: m -> [Room (UserData m)]

instance RoomGroup (Room u) where
    roomsOf m = [m]

instance (RoomGroup rs) => RoomGroup [rs] where
    roomsOf = concatMap roomsOf

instance (UserData c ~ UserData m,RoomGroup c,RoomGroup m) => RoomGroup (c,m) where
    roomsOf (c,m) = roomsOf c ++ roomsOf m


