{-# LANGUAGE TypeFamilies #-}
module PrioritySync.Internal.Constrained
    (Constrained(..))
    where

import PrioritySync.Internal.UserData
import PrioritySync.Internal.RoomGroup
import PrioritySync.Internal.ClaimContext
import PrioritySync.Internal.Room
import PrioritySync.Internal.RoomConstraint

-- | Require that all 'RoomConstraint's be satisfied when acquiring a 'Room'.
data Constrained u = Constrained

type instance UserData (Constrained u) = u

instance RoomGroup (Constrained u) where
    roomsOf = const []

instance (RoomConstraint u) => ClaimContext (Constrained u) where
    type ClaimHandle (Constrained u) = ()
    approveClaimsEntering _ cs = approveClaims cs >> return ()
    approveClaimsExiting _ cs = approveClaims cs >> return ()
    waitingAction _ () = return ()


