[Xmonad] darcs patch: Main.hs: get rid off non-standard patter...
(and 4 more)
David Roundy
droundy at darcs.net
Wed Jun 20 13:39:17 EDT 2007
On Wed, Jun 20, 2007 at 07:29:46PM +0200, joachim.fasting at gmail.com wrote:
> [Main.hs: get rid off non-standard pattern guards.
> joachim.fasting at gmail.com**20070618222530
> Use nested case statements when creating the winset binding.
> Looks _really_ ugly, compared to the original, and adds 3 loc.
> ] {
> hunk ./Main.hs 53
> - let winset | ("--resume" : s : _) <- args
> - , [(x, "")] <- reads s = x
> - | otherwise = new [0..fromIntegral workspaces-1] (fromIntegral $ length xinesc)
> + let defaultWinset = new [0..fromIntegral workspaces-1] (fromIntegral $ length xinesc)
> + winset = case args of
> + ("--resume" : s : _) -> case reads s of
> + [(x, [])] -> x
> + _ -> defaultWinset
> + _ -> defaultWinset
This could be prettier with
let winset = maybe (new [0..fromIntegral workspaces-1] (fromIntegral $ length xinesc)) id $
do ("--resume" : s : _) <- args
[(x, "")] <- reads s
return x
which I think is closer to what the pattern guards desugar to.
> [Remove use of ';' to circumvent layout rules.
> joachim.fasting at gmail.com**20070620165951
> This adds about 3 loc, but using ';' is cheating anyways.
> ] {
> hunk ./Main.hs 60
> - safeLayouts = case defaultLayouts of [] -> (full, []); (x:xs) -> (x,xs)
> + safeLayouts = case defaultLayouts of
> + [] -> (full, [])
> + (x:xs) -> (x,xs)
It's a question of style preference, but I consider
safeLayouts = case defaultLayouts of [] -> (full, [])
(x:xs) -> (x,xs)
to be more readable. In isolation it's equally readable, but it allows me
to see more code on the screen simultaneously.
--
David Roundy
Department of Physics
Oregon State University
More information about the Xmonad
mailing list