{-# LANGUAGE ViewPatterns, MultiWayIf #-}
module XMonad.Actions.CycleWindows (
cycleRecentWindows,
cycleStacks',
rotOpposite', rotOpposite,
rotFocused', rotFocusedUp, rotFocusedDown, shiftToFocus',
rotUnfocused', rotUnfocusedUp, rotUnfocusedDown,
rotUp, rotDown
) where
import XMonad
import XMonad.Prelude
import qualified XMonad.StackSet as W
import qualified Data.List.NonEmpty as NE
import XMonad.Actions.RotSlaves
import XMonad.Actions.Repeatable (repeatableSt)
import Control.Arrow (second)
import Control.Monad.Trans (lift)
cycleRecentWindows :: [KeySym]
-> KeySym
-> KeySym
-> X ()
cycleRecentWindows :: [KeySym] -> KeySym -> KeySym -> X ()
cycleRecentWindows = (Stack KeySym -> [Stack KeySym])
-> [KeySym] -> KeySym -> KeySym -> X ()
cycleStacks' Stack KeySym -> [Stack KeySym]
forall {a}. (Eq a, Show a, Read a) => Stack a -> [Stack a]
stacks where
stacks :: Stack a -> [Stack a]
stacks Stack a
s = (a -> Stack a) -> [a] -> [Stack a]
forall a b. (a -> b) -> [a] -> [b]
map (a -> Stack a -> Stack a
forall a. (Eq a, Show a, Read a) => a -> Stack a -> Stack a
`shiftToFocus'` Stack a
s) (Stack a -> [a]
forall {a}. Stack a -> [a]
wins Stack a
s)
wins :: Stack a -> [a]
wins (W.Stack a
t [a]
l [a]
r) = a
t a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
r [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a] -> [a]
forall a. [a] -> [a]
reverse [a]
l
cycleStacks' :: (W.Stack Window -> [W.Stack Window])
-> [KeySym]
-> KeySym
-> KeySym
-> X ()
cycleStacks' :: (Stack KeySym -> [Stack KeySym])
-> [KeySym] -> KeySym -> KeySym -> X ()
cycleStacks' Stack KeySym -> [Stack KeySym]
filteredPerms [KeySym]
mods KeySym
keyNext KeySym
keyPrev = do
[Stack KeySym]
stacks <- (XState -> [Stack KeySym]) -> X [Stack KeySym]
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets ((XState -> [Stack KeySym]) -> X [Stack KeySym])
-> (XState -> [Stack KeySym]) -> X [Stack KeySym]
forall a b. (a -> b) -> a -> b
$ [Stack KeySym]
-> (Stack KeySym -> [Stack KeySym])
-> Maybe (Stack KeySym)
-> [Stack KeySym]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Stack KeySym -> [Stack KeySym]
filteredPerms
(Maybe (Stack KeySym) -> [Stack KeySym])
-> (XState -> Maybe (Stack KeySym)) -> XState -> [Stack KeySym]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Workspace WorkspaceId (Layout KeySym) KeySym
-> Maybe (Stack KeySym)
forall i l a. Workspace i l a -> Maybe (Stack a)
W.stack (Workspace WorkspaceId (Layout KeySym) KeySym
-> Maybe (Stack KeySym))
-> (XState -> Workspace WorkspaceId (Layout KeySym) KeySym)
-> XState
-> Maybe (Stack KeySym)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Screen WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> Workspace WorkspaceId (Layout KeySym) KeySym
forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
W.workspace (Screen WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> Workspace WorkspaceId (Layout KeySym) KeySym)
-> (XState
-> Screen WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> XState
-> Workspace WorkspaceId (Layout KeySym) KeySym
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> Screen WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
W.current (StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> Screen WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> (XState
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> XState
-> Screen WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XState
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
windowset
let
preview :: StateT Int X ()
preview = do
Int
i <- StateT Int X Int
forall s (m :: * -> *). MonadState s m => m s
get
X () -> StateT Int X ()
forall (m :: * -> *) a. Monad m => m a -> StateT Int m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (X () -> StateT Int X ())
-> (Stack KeySym -> X ()) -> Stack KeySym -> StateT Int X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ()
windows ((StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ())
-> (Stack KeySym
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> Stack KeySym
-> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
W.modify' ((Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> (Stack KeySym -> Stack KeySym -> Stack KeySym)
-> Stack KeySym
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Stack KeySym -> Stack KeySym -> Stack KeySym
forall a b. a -> b -> a
const (Stack KeySym -> StateT Int X ())
-> Stack KeySym -> StateT Int X ()
forall a b. (a -> b) -> a -> b
$ [Stack KeySym]
stacks [Stack KeySym] -> Int -> Stack KeySym
forall a. HasCallStack => [a] -> Int -> a
!! (Int
i Int -> Int -> Int
forall a. Integral a => a -> a -> a
`mod` Int
n)
where n :: Int
n = [Stack KeySym] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Stack KeySym]
stacks
X ((), Int) -> X ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (X ((), Int) -> X ()) -> X ((), Int) -> X ()
forall a b. (a -> b) -> a -> b
$ Int
-> [KeySym]
-> KeySym
-> (EventType -> KeySym -> StateT Int X ())
-> X ((), Int)
forall a s.
Monoid a =>
s
-> [KeySym]
-> KeySym
-> (EventType -> KeySym -> StateT s X a)
-> X (a, s)
repeatableSt Int
0 [KeySym]
mods KeySym
keyNext ((EventType -> KeySym -> StateT Int X ()) -> X ((), Int))
-> (EventType -> KeySym -> StateT Int X ()) -> X ((), Int)
forall a b. (a -> b) -> a -> b
$ \EventType
t KeySym
s -> if
| EventType
t EventType -> EventType -> Bool
forall a. Eq a => a -> a -> Bool
== EventType
keyPress Bool -> Bool -> Bool
&& KeySym
s KeySym -> KeySym -> Bool
forall a. Eq a => a -> a -> Bool
== KeySym
keyNext -> (Int -> Int) -> StateT Int X ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify Int -> Int
forall a. Enum a => a -> a
succ
| EventType
t EventType -> EventType -> Bool
forall a. Eq a => a -> a -> Bool
== EventType
keyPress Bool -> Bool -> Bool
&& KeySym
s KeySym -> KeySym -> Bool
forall a. Eq a => a -> a -> Bool
== KeySym
keyPrev -> (Int -> Int) -> StateT Int X ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify Int -> Int
forall a. Enum a => a -> a
pred
| EventType
t EventType -> EventType -> Bool
forall a. Eq a => a -> a -> Bool
== EventType
keyPress Bool -> Bool -> Bool
&& KeySym
s KeySym -> [KeySym] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [KeySym
xK_0..KeySym
xK_9] -> Int -> StateT Int X ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (KeySym -> Int
numKeyToN KeySym
s)
| Bool
otherwise -> StateT Int X ()
preview
where numKeyToN :: KeySym -> Int
numKeyToN = Int -> Int -> Int
forall a. Num a => a -> a -> a
subtract Int
48 (Int -> Int) -> (KeySym -> Int) -> KeySym -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WorkspaceId -> Int
forall a. Read a => WorkspaceId -> a
read (WorkspaceId -> Int) -> (KeySym -> WorkspaceId) -> KeySym -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. KeySym -> WorkspaceId
forall a. Show a => a -> WorkspaceId
show
shiftToFocus' :: (Eq a, Show a, Read a) => a -> W.Stack a -> W.Stack a
shiftToFocus' :: forall a. (Eq a, Show a, Read a) => a -> Stack a -> Stack a
shiftToFocus' a
w s :: Stack a
s@(W.Stack a
_ [a]
ls [a]
_) = a -> [a] -> [a] -> Stack a
forall a. a -> [a] -> [a] -> Stack a
W.Stack a
w ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
revls') [a]
rs'
where ([a]
revls', [a]
rs') = Int -> [a] -> ([a], [a])
forall a. Int -> [a] -> ([a], [a])
splitAt ([a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
ls) ([a] -> ([a], [a])) -> ([a] -> [a]) -> [a] -> ([a], [a])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> [a] -> [a]
forall a. (a -> Bool) -> [a] -> [a]
filter (a -> a -> Bool
forall a. Eq a => a -> a -> Bool
/= a
w) ([a] -> ([a], [a])) -> [a] -> ([a], [a])
forall a b. (a -> b) -> a -> b
$ Stack a -> [a]
forall {a}. Stack a -> [a]
W.integrate Stack a
s
rotOpposite :: X()
rotOpposite :: X ()
rotOpposite = (StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ()
windows ((StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ())
-> (StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ()
forall a b. (a -> b) -> a -> b
$ (Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
W.modify' Stack KeySym -> Stack KeySym
forall a. Stack a -> Stack a
rotOpposite'
rotOpposite' :: W.Stack a -> W.Stack a
rotOpposite' :: forall a. Stack a -> Stack a
rotOpposite' (W.Stack a
t [a]
l [a]
r) = a -> [a] -> [a] -> Stack a
forall a. a -> [a] -> [a] -> Stack a
W.Stack a
t' [a]
l' [a]
r'
where rrvl :: [a]
rrvl = [a]
r [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a] -> [a]
forall a. [a] -> [a]
reverse [a]
l
part :: Int
part = ([a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
rrvl Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
2
([a]
l', [a] -> NonEmpty a
forall a. HasCallStack => [a] -> NonEmpty a
notEmpty -> a
t' :| [a]
r') = ([a] -> [a]) -> ([a], [a]) -> ([a], [a])
forall b c d. (b -> c) -> (d, b) -> (d, c)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second [a] -> [a]
forall a. [a] -> [a]
reverse (([a], [a]) -> ([a], [a]))
-> ([a] -> ([a], [a])) -> [a] -> ([a], [a])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [a] -> ([a], [a])
forall a. Int -> [a] -> ([a], [a])
splitAt ([a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
l) ([a] -> ([a], [a])) -> [a] -> ([a], [a])
forall a b. (a -> b) -> a -> b
$
[a] -> [a]
forall a. [a] -> [a]
reverse (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
take Int
part [a]
rrvl [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ a
t a -> [a] -> [a]
forall a. a -> [a] -> [a]
: Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop Int
part [a]
rrvl)
rotFocusedUp :: X ()
rotFocusedUp :: X ()
rotFocusedUp = (StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ()
windows ((StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ())
-> ((Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> (Stack KeySym -> Stack KeySym)
-> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
W.modify' ((Stack KeySym -> Stack KeySym) -> X ())
-> (Stack KeySym -> Stack KeySym) -> X ()
forall a b. (a -> b) -> a -> b
$ ([KeySym] -> [KeySym]) -> Stack KeySym -> Stack KeySym
forall a. ([a] -> [a]) -> Stack a -> Stack a
rotFocused' [KeySym] -> [KeySym]
forall a. [a] -> [a]
rotUp
rotFocusedDown :: X ()
rotFocusedDown :: X ()
rotFocusedDown = (StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ()
windows ((StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ())
-> ((Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> (Stack KeySym -> Stack KeySym)
-> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
W.modify' ((Stack KeySym -> Stack KeySym) -> X ())
-> (Stack KeySym -> Stack KeySym) -> X ()
forall a b. (a -> b) -> a -> b
$ ([KeySym] -> [KeySym]) -> Stack KeySym -> Stack KeySym
forall a. ([a] -> [a]) -> Stack a -> Stack a
rotFocused' [KeySym] -> [KeySym]
forall a. [a] -> [a]
rotDown
rotFocused' :: ([a] -> [a]) -> W.Stack a -> W.Stack a
rotFocused' :: forall a. ([a] -> [a]) -> Stack a -> Stack a
rotFocused' [a] -> [a]
_ s :: Stack a
s@(W.Stack a
_ [] []) = Stack a
s
rotFocused' [a] -> [a]
f (W.Stack a
t [] (a
r:[a]
rs)) = a -> [a] -> [a] -> Stack a
forall a. a -> [a] -> [a] -> Stack a
W.Stack a
t' [] (a
ra -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
rs')
where ([a] -> NonEmpty a
forall a. HasCallStack => [a] -> NonEmpty a
notEmpty -> a
t' :| [a]
rs') = [a] -> [a]
f (a
ta -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
rs)
rotFocused' [a] -> [a]
f s :: Stack a
s@W.Stack{} = ([a] -> [a]) -> Stack a -> Stack a
forall a. ([a] -> [a]) -> Stack a -> Stack a
rotSlaves' [a] -> [a]
f Stack a
s
rotUnfocusedUp :: X ()
rotUnfocusedUp :: X ()
rotUnfocusedUp = (StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ()
windows ((StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ())
-> ((Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> (Stack KeySym -> Stack KeySym)
-> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
W.modify' ((Stack KeySym -> Stack KeySym) -> X ())
-> (Stack KeySym -> Stack KeySym) -> X ()
forall a b. (a -> b) -> a -> b
$ ([KeySym] -> [KeySym]) -> Stack KeySym -> Stack KeySym
forall a. ([a] -> [a]) -> Stack a -> Stack a
rotUnfocused' [KeySym] -> [KeySym]
forall a. [a] -> [a]
rotUp
rotUnfocusedDown :: X ()
rotUnfocusedDown :: X ()
rotUnfocusedDown = (StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ()
windows ((StackSet WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> X ())
-> ((Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail)
-> (Stack KeySym -> Stack KeySym)
-> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Stack KeySym -> Stack KeySym)
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
-> StackSet
WorkspaceId (Layout KeySym) KeySym ScreenId ScreenDetail
forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
W.modify' ((Stack KeySym -> Stack KeySym) -> X ())
-> (Stack KeySym -> Stack KeySym) -> X ()
forall a b. (a -> b) -> a -> b
$ ([KeySym] -> [KeySym]) -> Stack KeySym -> Stack KeySym
forall a. ([a] -> [a]) -> Stack a -> Stack a
rotUnfocused' [KeySym] -> [KeySym]
forall a. [a] -> [a]
rotDown
rotUnfocused' :: ([a] -> [a]) -> W.Stack a -> W.Stack a
rotUnfocused' :: forall a. ([a] -> [a]) -> Stack a -> Stack a
rotUnfocused' [a] -> [a]
_ s :: Stack a
s@(W.Stack a
_ [] []) = Stack a
s
rotUnfocused' [a] -> [a]
f s :: Stack a
s@(W.Stack a
_ [] [a]
_ ) = ([a] -> [a]) -> Stack a -> Stack a
forall a. ([a] -> [a]) -> Stack a -> Stack a
rotSlaves' [a] -> [a]
f Stack a
s
rotUnfocused' [a] -> [a]
f (W.Stack a
t [a]
ls [a]
rs) = a -> [a] -> [a] -> Stack a
forall a. a -> [a] -> [a] -> Stack a
W.Stack a
t ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
revls') [a]
rs'
where (a
master :| [a]
revls) = NonEmpty a -> NonEmpty a
forall a. NonEmpty a -> NonEmpty a
NE.reverse (let a
l:[a]
ll = [a]
ls in a
l a -> [a] -> NonEmpty a
forall a. a -> [a] -> NonEmpty a
:| [a]
ll)
([a]
revls',[a]
rs') = Int -> [a] -> ([a], [a])
forall a. Int -> [a] -> ([a], [a])
splitAt ([a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
ls) ([a] -> [a]
f ([a] -> [a]) -> [a] -> [a]
forall a b. (a -> b) -> a -> b
$ a
mastera -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
revls [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a]
rs)