diff --git a/src/swarm-tui/Swarm/TUI/Controller.hs b/src/swarm-tui/Swarm/TUI/Controller.hs index 477b3d3cc..2c52afaf3 100644 --- a/src/swarm-tui/Swarm/TUI/Controller.hs +++ b/src/swarm-tui/Swarm/TUI/Controller.hs @@ -43,8 +43,6 @@ import Control.Monad (unless, void, when) import Control.Monad.Extra (whenJust) import Control.Monad.IO.Class (MonadIO (liftIO)) import Control.Monad.State (MonadState, execState) -import Data.Int (Int32) -import Data.List.Extra (enumerate) import Data.List.NonEmpty (NonEmpty (..)) import Data.List.NonEmpty qualified as NE import Data.Map qualified as M diff --git a/src/swarm-tui/Swarm/TUI/Controller/UpdateUI.hs b/src/swarm-tui/Swarm/TUI/Controller/UpdateUI.hs index b37e54c6e..8985c3cf1 100644 --- a/src/swarm-tui/Swarm/TUI/Controller/UpdateUI.hs +++ b/src/swarm-tui/Swarm/TUI/Controller/UpdateUI.hs @@ -17,6 +17,7 @@ import Control.Applicative (liftA2, pure) import Control.Lens as Lens import Control.Monad (unless, when) import Data.Foldable (toList) +import Data.List.Extra (enumerate) import Data.Maybe (isNothing) import Data.String (fromString) import Data.Text qualified as T @@ -40,7 +41,6 @@ import Swarm.TUI.Model.UI import Swarm.TUI.View.Objective qualified as GR import Witch (into) import Prelude hiding (Applicative (..)) -import Data.List.Extra (enumerate) -- | Update the UI. This function is used after running the -- game for some number of ticks. diff --git a/src/swarm-tui/Swarm/TUI/Controller/Util.hs b/src/swarm-tui/Swarm/TUI/Controller/Util.hs index 9b622e13b..3dadac994 100644 --- a/src/swarm-tui/Swarm/TUI/Controller/Util.hs +++ b/src/swarm-tui/Swarm/TUI/Controller/Util.hs @@ -13,6 +13,7 @@ import Control.Lens as Lens import Control.Monad (forM_, unless, when) import Control.Monad.IO.Class (MonadIO (liftIO), liftIO) import Control.Monad.State (MonadState, execState) +import Data.List.Extra (enumerate) import Data.Map qualified as M import Data.Set qualified as S import Data.Text (Text) @@ -35,7 +36,6 @@ import Swarm.Language.Syntax hiding (Key) import Swarm.TUI.Model import Swarm.TUI.Model.UI import Swarm.TUI.View.Util (generateModal) -import Swarm.Util (listEnums) import System.Clock (Clock (..), getTime) -- | Pattern synonyms to simplify brick event handler @@ -178,7 +178,7 @@ allHandlers :: (e1 -> e2) -> (e1 -> (Text, EventM Name AppState ())) -> [KeyEventHandler e2 (EventM Name AppState)] -allHandlers eEmbed f = map handleEvent1 listEnums +allHandlers eEmbed f = map handleEvent1 enumerate where handleEvent1 e1 = let (n, a) = f e1 in onEvent (eEmbed e1) n a diff --git a/src/swarm-tui/Swarm/TUI/Model/Event.hs b/src/swarm-tui/Swarm/TUI/Model/Event.hs index c75b7ff2c..3dbef00c5 100644 --- a/src/swarm-tui/Swarm/TUI/Model/Event.hs +++ b/src/swarm-tui/Swarm/TUI/Model/Event.hs @@ -18,9 +18,9 @@ module Swarm.TUI.Model.Event ( import Brick.Keybindings import Control.Arrow ((&&&)) import Data.Bifunctor (first) +import Data.List.Extra (enumerate) import Data.Text (Text) import Graphics.Vty qualified as V -import Swarm.Util (listEnums) data SwarmEvent = Main MainEvent @@ -219,7 +219,7 @@ defaultRobotPanelBindings = allBindings $ \case -- Helper methods allKeyEvents :: (Ord e, Bounded e, Enum e) => (e -> Text) -> KeyEvents e -allKeyEvents f = keyEvents $ map (f &&& id) listEnums +allKeyEvents f = keyEvents $ map (f &&& id) enumerate allBindings :: (Bounded e, Enum e) => (e -> [Binding]) -> [(e, [Binding])] allBindings f = map (\e -> (e, f e)) [minBound .. maxBound]