Minor style corrections in X.U.SpawnOnce

This commit is contained in:
Daniel Schoepe 2009-11-09 20:15:43 +00:00
parent da094a635d
commit e14dcd9aa6

View File

@ -26,14 +26,14 @@ data SpawnOnce = SpawnOnce { unspawnOnce :: (Set String) }
deriving (Read, Show, Typeable) deriving (Read, Show, Typeable)
instance ExtensionClass SpawnOnce where instance ExtensionClass SpawnOnce where
initialValue = SpawnOnce $ Set.empty initialValue = SpawnOnce Set.empty
extensionType = PersistentExtension extensionType = PersistentExtension
-- | The first time 'spawnOnce' is executed on a particular command, that -- | The first time 'spawnOnce' is executed on a particular command, that
-- command is executed. Subsequent invocations for a command do nothing. -- command is executed. Subsequent invocations for a command do nothing.
spawnOnce :: String -> X () spawnOnce :: String -> X ()
spawnOnce xs = do spawnOnce xs = do
b <- fmap (Set.member xs . unspawnOnce) $ getState b <- fmap (Set.member xs . unspawnOnce) getState
when (not b) $ do when (not b) $ do
spawn xs spawn xs
modifyState (SpawnOnce . Set.insert xs . unspawnOnce) modifyState (SpawnOnce . Set.insert xs . unspawnOnce)