module XMonad.Actions.Sift (
siftUp,
siftDown,
) where
import XMonad.StackSet (Stack (Stack), StackSet, modify')
import XMonad.Util.Stack (reverseS)
siftUp, siftDown :: StackSet i l a s sd -> StackSet i l a s sd
siftUp :: forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
siftUp = (Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' Stack a -> Stack a
forall a. Stack a -> Stack a
siftUp'
siftDown :: forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
siftDown = (Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' (Stack a -> Stack a
forall a. Stack a -> Stack a
reverseS (Stack a -> Stack a) -> (Stack a -> Stack a) -> Stack a -> Stack a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Stack a -> Stack a
forall a. Stack a -> Stack a
siftUp' (Stack a -> Stack a) -> (Stack a -> Stack a) -> Stack a -> Stack a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Stack a -> Stack a
forall a. Stack a -> Stack a
reverseS)
siftUp' :: Stack a -> Stack a
siftUp' :: forall a. Stack a -> Stack a
siftUp' (Stack a
t (a
l:[a]
ls) [a]
rs) = a -> [a] -> [a] -> Stack a
forall a. a -> [a] -> [a] -> Stack a
Stack a
t [a]
ls (a
la -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
rs)
siftUp' (Stack a
t [] [a]
rs) =
case [a] -> [a]
forall a. [a] -> [a]
reverse [a]
rs of
(a
x:[a]
xs) -> a -> [a] -> [a] -> Stack a
forall a. a -> [a] -> [a] -> Stack a
Stack a
t ([a]
xs [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a
x]) []
[] -> a -> [a] -> [a] -> Stack a
forall a. a -> [a] -> [a] -> Stack a
Stack a
t [] []