
25 Jun
2007
25 Jun
'07
12:43 a.m.
droundy: > Sun Jun 24 07:48:54 PDT 2007 David Roundy> * simplify StackSet.delete > Content-Description: A darcs patch for your repository! > > New patches: > > [simplify StackSet.delete > David Roundy **20070624144854] > < > > { > hunk ./StackSet.hs 431 > -- * otherwise, delete doesn't affect the master. > -- > delete :: (Integral i, Ord a, Eq s) => a -> StackSet i a s -> StackSet i a s > -delete w s | Just w == peek s = remove s -- common case. > +delete w s | Just w == peek s = modify Nothing (filter (/= w)) s -- common case. > | otherwise = maybe s (removeWindow.tag.workspace.current $ s) (findIndex w s) > where > -- find and remove window script > hunk ./StackSet.hs 435 > - removeWindow o n = foldr ($) s [view o,remove,view n] > - > - -- actual removal logic, and focus/master logic: > - remove = modify Nothing $ \c -> > - if focus c == w > - then case c of > - Stack _ ls (r:rs) -> Just $ Stack r ls rs -- try down first > - Stack _ (l:ls) [] -> Just $ Stack l ls [] -- else up > - Stack _ [] [] -> Nothing > - else Just $ c { up = w `L.delete` up c, down = w `L.delete` down c } > + removeWindow o n = foldr ($) s [view o,modify Nothing (filter (/= w)),view n] How does this ensure the old semantics for where focus goes, is preserved? Does it rely on filter implementing the same focus semantics as 'remove' did? -- Don