Skip to content

Commit

Permalink
refactor: move updateLast to Utility module
Browse files Browse the repository at this point in the history
  • Loading branch information
AliNisarAhmed authored and smallhadroncollider committed Aug 6, 2021
1 parent 4fab856 commit 624fe5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/Taskell/Data/Utility.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Taskell.Data.Utility where

updateLast :: (a -> a) -> [a] -> [a]
updateLast _ [] = []
updateLast f [k] = [f k]
updateLast f (y : ys) = y : updateLast f ys
8 changes: 2 additions & 6 deletions src/Taskell/UI/Draw/Modal/Help.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Taskell.UI.Theme (taskCurrentAttr)
import Control.Lens ((^.))
import Taskell.Events.State.Types (mode)
import qualified Taskell.Events.State.Types.Mode as M
import Taskell.Data.Utility (updateLast)

descriptions :: [([ActionType], Text)]
descriptions =
Expand Down Expand Up @@ -73,14 +74,9 @@ help s = do

applyScroll :: M.HelpScrollPosition -> [TWidget] -> [TWidget]
applyScroll _ [] = []
applyScroll sp list@(x:xs) =
applyScroll sp (x:xs) =
case sp of
M.Top ->
visible x : xs
M.Bottom ->
updateLast visible xs
where
updateLast :: (a -> a) -> [a] -> [a]
updateLast _ [] = []
updateLast f [k] = [f k]
updateLast f (y: ys) = y : updateLast f ys

0 comments on commit 624fe5e

Please sign in to comment.