From 4f74a9cf9027e0a26dfdad093fdabea2be065d32 Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Mon, 30 Sep 2024 06:25:47 -0500 Subject: [PATCH] Refactor: move ResourceLoading to swarm-util --- app/game/Main.hs | 2 +- src/swarm-engine/Swarm/Game/Achievement/Persistence.hs | 2 +- src/swarm-engine/Swarm/Game/ScenarioInfo.hs | 2 +- src/swarm-engine/Swarm/Game/State/Robot.hs | 2 +- src/swarm-engine/Swarm/Game/State/Runtime.hs | 2 +- src/swarm-engine/Swarm/Game/Step/Const.hs | 2 +- src/swarm-engine/Swarm/Game/Step/Util.hs | 2 +- src/swarm-scenario/Swarm/Game/Entity.hs | 2 +- src/swarm-scenario/Swarm/Game/Recipe.hs | 2 +- src/swarm-scenario/Swarm/Game/Scenario.hs | 2 +- src/swarm-scenario/Swarm/Game/State/Config.hs | 2 +- src/swarm-scenario/Swarm/Game/Terrain.hs | 2 +- src/swarm-scenario/Swarm/Game/World/Load.hs | 2 +- src/swarm-tui/Swarm/TUI/Controller.hs | 2 +- src/swarm-tui/Swarm/TUI/Model/KeyBindings.hs | 2 +- src/swarm-tui/Swarm/TUI/Model/UI.hs | 2 +- .../Swarm/Game => swarm-util/Swarm}/ResourceLoading.hs | 2 +- swarm.cabal | 4 ++-- 18 files changed, 19 insertions(+), 19 deletions(-) rename src/{swarm-scenario/Swarm/Game => swarm-util/Swarm}/ResourceLoading.hs (99%) diff --git a/app/game/Main.hs b/app/game/Main.hs index cde368d9c..500ae6ec7 100644 --- a/app/game/Main.hs +++ b/app/game/Main.hs @@ -17,7 +17,7 @@ import GitHash (GitInfo, giBranch, giHash, tGitInfoCwdTry) import Options.Applicative import Options.Applicative.Help hiding (color, fullDesc) import Swarm.App (appMain) -import Swarm.Game.ResourceLoading (getSwarmConfigIniFile) +import Swarm.ResourceLoading (getSwarmConfigIniFile) import Swarm.Language.Format import Swarm.Language.LSP (lspMain) import Swarm.Language.Parser.Core (LanguageVersion (..)) diff --git a/src/swarm-engine/Swarm/Game/Achievement/Persistence.hs b/src/swarm-engine/Swarm/Game/Achievement/Persistence.hs index c54317f00..62b240f41 100644 --- a/src/swarm-engine/Swarm/Game/Achievement/Persistence.hs +++ b/src/swarm-engine/Swarm/Game/Achievement/Persistence.hs @@ -16,7 +16,7 @@ import Data.Yaml qualified as Y import Swarm.Failure import Swarm.Game.Achievement.Attainment import Swarm.Game.Achievement.Definitions -import Swarm.Game.ResourceLoading (getSwarmAchievementsPath) +import Swarm.ResourceLoading (getSwarmAchievementsPath) import Swarm.Util.Effect (forMW) import System.Directory (doesDirectoryExist, doesFileExist, listDirectory) import System.FilePath (()) diff --git a/src/swarm-engine/Swarm/Game/ScenarioInfo.hs b/src/swarm-engine/Swarm/Game/ScenarioInfo.hs index 52a4014fd..bb52d7ec5 100644 --- a/src/swarm-engine/Swarm/Game/ScenarioInfo.hs +++ b/src/swarm-engine/Swarm/Game/ScenarioInfo.hs @@ -57,7 +57,7 @@ import Data.Sequence qualified as Seq import Data.Text (Text) import Data.Yaml as Y import Swarm.Failure -import Swarm.Game.ResourceLoading (getDataDirSafe, getSwarmSavePath) +import Swarm.ResourceLoading (getDataDirSafe, getSwarmSavePath) import Swarm.Game.Scenario import Swarm.Game.Scenario.Scoring.CodeSize import Swarm.Game.Scenario.Status diff --git a/src/swarm-engine/Swarm/Game/State/Robot.hs b/src/swarm-engine/Swarm/Game/State/Robot.hs index c3b31037b..2b38a1bd5 100644 --- a/src/swarm-engine/Swarm/Game/State/Robot.hs +++ b/src/swarm-engine/Swarm/Game/State/Robot.hs @@ -71,7 +71,7 @@ import Data.Tuple (swap) import GHC.Generics (Generic) import Swarm.Game.CESK (CESK (Waiting)) import Swarm.Game.Location -import Swarm.Game.ResourceLoading (NameGenerator) +import Swarm.ResourceLoading (NameGenerator) import Swarm.Game.Robot import Swarm.Game.Robot.Concrete import Swarm.Game.State.Config diff --git a/src/swarm-engine/Swarm/Game/State/Runtime.hs b/src/swarm-engine/Swarm/Game/State/Runtime.hs index 19244915c..b52819c5c 100644 --- a/src/swarm-engine/Swarm/Game/State/Runtime.hs +++ b/src/swarm-engine/Swarm/Game/State/Runtime.hs @@ -35,7 +35,7 @@ import Data.Text (Text) import Swarm.Failure (SystemFailure) import Swarm.Game.Land import Swarm.Game.Recipe (loadRecipes) -import Swarm.Game.ResourceLoading (initNameGenerator, readAppData) +import Swarm.ResourceLoading (initNameGenerator, readAppData) import Swarm.Game.Scenario (GameStateInputs (..), ScenarioInputs (..)) import Swarm.Game.ScenarioInfo (ScenarioCollection, loadScenarios) import Swarm.Game.State.Substate diff --git a/src/swarm-engine/Swarm/Game/Step/Const.hs b/src/swarm-engine/Swarm/Game/Step/Const.hs index 39f309fcb..eac372038 100644 --- a/src/swarm-engine/Swarm/Game/Step/Const.hs +++ b/src/swarm-engine/Swarm/Game/Step/Const.hs @@ -55,7 +55,7 @@ import Swarm.Game.Exception import Swarm.Game.Land import Swarm.Game.Location import Swarm.Game.Recipe -import Swarm.Game.ResourceLoading (getDataFileNameSafe) +import Swarm.ResourceLoading (getDataFileNameSafe) import Swarm.Game.Robot import Swarm.Game.Robot.Activity import Swarm.Game.Robot.Concrete diff --git a/src/swarm-engine/Swarm/Game/Step/Util.hs b/src/swarm-engine/Swarm/Game/Step/Util.hs index 04f9fddc6..303deda4e 100644 --- a/src/swarm-engine/Swarm/Game/Step/Util.hs +++ b/src/swarm-engine/Swarm/Game/Step/Util.hs @@ -27,7 +27,7 @@ import Swarm.Game.Device import Swarm.Game.Entity hiding (empty, lookup, singleton, union) import Swarm.Game.Exception import Swarm.Game.Location -import Swarm.Game.ResourceLoading (NameGenerator (..)) +import Swarm.ResourceLoading (NameGenerator (..)) import Swarm.Game.Robot import Swarm.Game.Scenario.Topography.Structure.Recognition.Tracking qualified as SRT import Swarm.Game.State diff --git a/src/swarm-scenario/Swarm/Game/Entity.hs b/src/swarm-scenario/Swarm/Game/Entity.hs index b7a263a7b..2f936a906 100644 --- a/src/swarm-scenario/Swarm/Game/Entity.hs +++ b/src/swarm-scenario/Swarm/Game/Entity.hs @@ -126,7 +126,7 @@ import Swarm.Game.Entity.Cosmetic (WorldAttr (..)) import Swarm.Game.Entity.Cosmetic.Assignment (worldAttributes) import Swarm.Game.Ingredients import Swarm.Game.Location -import Swarm.Game.ResourceLoading (getDataFileNameSafe) +import Swarm.ResourceLoading (getDataFileNameSafe) import Swarm.Game.Terrain (TerrainType) import Swarm.Language.Capability import Swarm.Language.Syntax (Syntax) diff --git a/src/swarm-scenario/Swarm/Game/Recipe.hs b/src/swarm-scenario/Swarm/Game/Recipe.hs index 0798d40b9..87f7419d1 100644 --- a/src/swarm-scenario/Swarm/Game/Recipe.hs +++ b/src/swarm-scenario/Swarm/Game/Recipe.hs @@ -70,7 +70,7 @@ import GHC.Generics (Generic) import Swarm.Failure import Swarm.Game.Entity as E import Swarm.Game.Ingredients -import Swarm.Game.ResourceLoading (getDataFileNameSafe) +import Swarm.ResourceLoading (getDataFileNameSafe) import Swarm.Util.Effect (withThrow) import Swarm.Util.Lens (makeLensesNoSigs) import Swarm.Util.Yaml diff --git a/src/swarm-scenario/Swarm/Game/Scenario.hs b/src/swarm-scenario/Swarm/Game/Scenario.hs index b612fb155..9b3a6c3cd 100644 --- a/src/swarm-scenario/Swarm/Game/Scenario.hs +++ b/src/swarm-scenario/Swarm/Game/Scenario.hs @@ -80,7 +80,7 @@ import Swarm.Game.Entity.Cosmetic.Assignment (worldAttributes) import Swarm.Game.Land import Swarm.Game.Location (Location) import Swarm.Game.Recipe -import Swarm.Game.ResourceLoading (getDataFileNameSafe) +import Swarm.ResourceLoading (getDataFileNameSafe) import Swarm.Game.Robot (TRobot, trobotLocation, trobotName) import Swarm.Game.Scenario.Objective (Objective) import Swarm.Game.Scenario.Objective.Validation diff --git a/src/swarm-scenario/Swarm/Game/State/Config.hs b/src/swarm-scenario/Swarm/Game/State/Config.hs index f2e71322c..92dc0e741 100644 --- a/src/swarm-scenario/Swarm/Game/State/Config.hs +++ b/src/swarm-scenario/Swarm/Game/State/Config.hs @@ -7,7 +7,7 @@ module Swarm.Game.State.Config where import Data.Map (Map) import Data.Text (Text) -import Swarm.Game.ResourceLoading (NameGenerator) +import Swarm.ResourceLoading (NameGenerator) import Swarm.Game.Scenario (GameStateInputs) -- | Record to pass information needed to create an initial diff --git a/src/swarm-scenario/Swarm/Game/Terrain.hs b/src/swarm-scenario/Swarm/Game/Terrain.hs index 0ca5284b3..7cbc7de55 100644 --- a/src/swarm-scenario/Swarm/Game/Terrain.hs +++ b/src/swarm-scenario/Swarm/Game/Terrain.hs @@ -38,7 +38,7 @@ import GHC.Generics (Generic) import Swarm.Failure import Swarm.Game.Display import Swarm.Game.Entity.Cosmetic (WorldAttr (..)) -import Swarm.Game.ResourceLoading (getDataFileNameSafe) +import Swarm.ResourceLoading (getDataFileNameSafe) import Swarm.Util (enumeratedMap, quote) import Swarm.Util.Effect (withThrow) diff --git a/src/swarm-scenario/Swarm/Game/World/Load.hs b/src/swarm-scenario/Swarm/Game/World/Load.hs index 38b0394bd..16b73fbf6 100644 --- a/src/swarm-scenario/Swarm/Game/World/Load.hs +++ b/src/swarm-scenario/Swarm/Game/World/Load.hs @@ -18,7 +18,7 @@ import Data.Sequence (Seq) import Data.Text (Text) import Swarm.Failure (Asset (..), AssetData (..), LoadingFailure (..), SystemFailure (..)) import Swarm.Game.Land -import Swarm.Game.ResourceLoading (getDataDirSafe) +import Swarm.ResourceLoading (getDataDirSafe) import Swarm.Game.World.Parse (parseWExp, runParser) import Swarm.Game.World.Typecheck import Swarm.Pretty (prettyText) diff --git a/src/swarm-tui/Swarm/TUI/Controller.hs b/src/swarm-tui/Swarm/TUI/Controller.hs index 1b9e01bae..ba88a9740 100644 --- a/src/swarm-tui/Swarm/TUI/Controller.hs +++ b/src/swarm-tui/Swarm/TUI/Controller.hs @@ -60,7 +60,7 @@ import Swarm.Game.Achievement.Definitions import Swarm.Game.CESK (CESK (Out), Frame (FApp, FExec, FSuspend)) import Swarm.Game.Entity hiding (empty) import Swarm.Game.Land -import Swarm.Game.ResourceLoading (getSwarmHistoryPath) +import Swarm.ResourceLoading (getSwarmHistoryPath) import Swarm.Game.Robot.Concrete import Swarm.Game.ScenarioInfo import Swarm.Game.State diff --git a/src/swarm-tui/Swarm/TUI/Model/KeyBindings.hs b/src/swarm-tui/Swarm/TUI/Model/KeyBindings.hs index 1f6386a5d..b85acf824 100644 --- a/src/swarm-tui/Swarm/TUI/Model/KeyBindings.hs +++ b/src/swarm-tui/Swarm/TUI/Model/KeyBindings.hs @@ -23,7 +23,7 @@ import Data.Maybe (fromMaybe, mapMaybe) import Data.Text (Text) import Data.Text qualified as T import Swarm.Failure (Asset (..), LoadingFailure (..), SystemFailure (..)) -import Swarm.Game.ResourceLoading (getSwarmConfigIniFile) +import Swarm.ResourceLoading (getSwarmConfigIniFile) import Swarm.Pretty (prettyText) import Swarm.TUI.Controller.EventHandlers import Swarm.TUI.Model diff --git a/src/swarm-tui/Swarm/TUI/Model/UI.hs b/src/swarm-tui/Swarm/TUI/Model/UI.hs index 9a1a07345..bb3eb2742 100644 --- a/src/swarm-tui/Swarm/TUI/Model/UI.hs +++ b/src/swarm-tui/Swarm/TUI/Model/UI.hs @@ -40,7 +40,7 @@ import Swarm.Failure (SystemFailure) import Swarm.Game.Achievement.Attainment import Swarm.Game.Achievement.Definitions import Swarm.Game.Achievement.Persistence -import Swarm.Game.ResourceLoading (getSwarmHistoryPath) +import Swarm.ResourceLoading (getSwarmHistoryPath) import Swarm.TUI.Editor.Model import Swarm.TUI.Inventory.Sorting import Swarm.TUI.Launch.Model diff --git a/src/swarm-scenario/Swarm/Game/ResourceLoading.hs b/src/swarm-util/Swarm/ResourceLoading.hs similarity index 99% rename from src/swarm-scenario/Swarm/Game/ResourceLoading.hs rename to src/swarm-util/Swarm/ResourceLoading.hs index 652fd389f..84493687b 100644 --- a/src/swarm-scenario/Swarm/Game/ResourceLoading.hs +++ b/src/swarm-util/Swarm/ResourceLoading.hs @@ -5,7 +5,7 @@ -- Description: Fetching game data -- -- Various utilities related to loading game data files. -module Swarm.Game.ResourceLoading ( +module Swarm.ResourceLoading ( -- * Generic data access getDataDirSafe, getDataFileNameSafe, diff --git a/swarm.cabal b/swarm.cabal index 808b3fabe..351c6437d 100644 --- a/swarm.cabal +++ b/swarm.cabal @@ -596,7 +596,6 @@ library swarm-scenario Swarm.Game.Ingredients Swarm.Game.Land Swarm.Game.Recipe - Swarm.Game.ResourceLoading Swarm.Game.Robot Swarm.Game.Robot.Walk Swarm.Game.Scenario @@ -848,6 +847,7 @@ library swarm-util import: stan-config, common, ghc2021-extensions, aeson, + array, base, boolexpr, clock, @@ -882,6 +882,7 @@ library swarm-util Swarm.Failure Swarm.Language.Syntax.Direction Swarm.Pretty + Swarm.ResourceLoading Swarm.Util Swarm.Util.Effect Swarm.Util.Erasable @@ -1103,7 +1104,6 @@ executable swarm build-depends: swarm:swarm-engine, swarm:swarm-lang, - swarm:swarm-scenario, swarm:swarm-tui, swarm:swarm-util, swarm:swarm-web,