From ddff290f6689b3a13fe418e01c2dad8233b58488 Mon Sep 17 00:00:00 2001 From: "joachim.fasting" Date: Wed, 20 Jun 2007 13:28:05 +0200 Subject: Combo.hs: use case instead of non-standard pattern matching. Also uses fmap/maybe instead of do/case, which makes the code look a little cleaner (imo). Please note that I've only been able to test this briefly, but it seems to be working like it's supposed to. darcs-hash:20070620112805-ea16c-d246e45889110c7f28da80adbcfc968139f77130.gz --- Combo.hs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'Combo.hs') diff --git a/Combo.hs b/Combo.hs index 9dd99c8..cdf4092 100644 --- a/Combo.hs +++ b/Combo.hs @@ -48,13 +48,10 @@ combo origls super = Layout { doLayout = \r s -> arrange r (integrate s), modify (map differentiate $ wss (take (length rs) $ map snd origls) origws) return $ concat out - message m | Just UnDoLayout <- fromMessage m = - do (super':ls') <- broadcastPrivate UnDoLayout (super:map fst origls) - return $ Just $ combo (zip ls' $ map snd origls) super' - message m = do msuper' <- modifyLayout super m - case msuper' of - Nothing -> return Nothing - Just super' -> return $ Just $ combo origls super' + message m = case fromMessage m of + Just UnDoLayout -> fmap (\(super':ls') -> Just $ combo (zip ls' $ map snd origls) super') + (broadcastPrivate UnDoLayout (super:map fst origls)) + _ -> fmap (maybe Nothing (Just . combo origls)) (modifyLayout super m) broadcastPrivate :: Message a => a -> [Layout b] -> X [Layout b] broadcastPrivate a ol = mapM f ol -- cgit v1.2.3