Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle Split swarm libraries #1070

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/swarm-app/Swarm/Web.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ import Servant
import Swarm.Game.Robot
import Swarm.Game.Scenario.Objective
import Swarm.Game.Scenario.Objective.Graph
import Swarm.TUI.Model.Goal
import Swarm.Game.Scenario.Objective.WinCheck
import Swarm.Game.State
import Swarm.TUI.Model
import Swarm.TUI.Model.Goal
import Swarm.TUI.Model.UI
import System.Timeout (timeout)

Expand Down
6 changes: 3 additions & 3 deletions src/swarm-game/Swarm/Game/Display.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
module Swarm.Game.Display (
-- * The display record
Priority,
Attribute(..),
Attribute (..),
Display,

-- ** Fields
Expand All @@ -41,12 +41,12 @@ import Data.Hashable (Hashable)
import Data.Map (Map)
import Data.Map qualified as M
import Data.Maybe (fromMaybe, isJust)
import Data.Text (Text)
import Data.Yaml
import GHC.Generics (Generic)
import Swarm.Game.Util.Yaml (FromJSONE (..), With (runE), getE, liftE, withObjectE)
import Swarm.Language.Syntax (AbsoluteDir (..), Direction (..))
import Swarm.Util.Util (maxOn)
import Swarm.Game.Util.Yaml (FromJSONE (..), With (runE), getE, liftE, withObjectE)
import Data.Text (Text)

-- | Display priority. Entities with higher priority will be drawn on
-- top of entities with lower priority.
Expand Down
4 changes: 2 additions & 2 deletions src/swarm-game/Swarm/Game/Entity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ import Data.Text qualified as T
import Data.Yaml
import GHC.Generics (Generic)
import Swarm.Game.Display
import Swarm.Language.Capability
import Swarm.Util.Util (binTuples, dataNotFound, getDataFileNameSafe, plural, reflow, (?))
import Swarm.Game.Location
import Swarm.Game.Util.Yaml
import Swarm.Language.Capability
import Swarm.Util.Util (binTuples, dataNotFound, getDataFileNameSafe, plural, reflow, (?))
import Text.Read (readMaybe)
import Witch
import Prelude hiding (lookup)
Expand Down
2 changes: 1 addition & 1 deletion src/swarm-game/Swarm/Game/Exception.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import Data.Set qualified as S
import Data.Text (Text)
import Data.Text qualified as T
import GHC.Generics (Generic)
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Entity (EntityMap, deviceForCap, entityName)
import Swarm.Language.Capability (Capability (CGod), capabilityName)
import Swarm.Language.Pretty (prettyText)
import Swarm.Language.Requirement (Requirements (..))
import Swarm.Language.Syntax (Const, Term)
import Swarm.Game.Achievement.Definitions
import Swarm.Util.Util
import Witch (from)

Expand Down
7 changes: 3 additions & 4 deletions src/swarm-game/Swarm/Game/Location.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ module Swarm.Game.Location (
) where

import Data.Aeson (FromJSONKey, ToJSONKey)
import Data.Function ((&))
import Data.Int (Int32)
import Data.Map (Map)
import Data.Map qualified as M
import Data.Yaml (FromJSON (parseJSON), ToJSON (toJSON))
import Linear (V2 (..))
import Linear.Affine (Point (..), origin)
import Data.Map (Map)
import Data.Map qualified as M
import Data.Function ((&))

-- | A Location is a pair of (x,y) coordinates, both up to 32 bits.
-- The positive x-axis points east and the positive y-axis points
Expand Down Expand Up @@ -70,7 +70,6 @@ instance FromJSON Location where
instance ToJSON Location where
toJSON (P v) = toJSON v


-- | Manhattan distance between world locations.
manhattan :: Location -> Location -> Int32
manhattan (Location x1 y1) (Location x2 y2) = abs (x1 - x2) + abs (y1 - y2)
Expand Down
2 changes: 1 addition & 1 deletion src/swarm-game/Swarm/Game/Recipe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ import Control.Algebra (Has)
import Control.Carrier.Lift (Lift, sendIO)
import Control.Carrier.Throw.Either (runThrow, throwError)
import Swarm.Game.Entity as E
import Swarm.Util.Util
import Swarm.Game.Util.Yaml
import Swarm.Util.Util

-- | An ingredient list is a list of entities with multiplicity. It
-- is polymorphic in the entity type so that we can use either
Expand Down
4 changes: 2 additions & 2 deletions src/swarm-game/Swarm/Game/Robot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ import Linear
import Swarm.Game.CESK
import Swarm.Game.Display (Display, curOrientation, defaultRobotDisplay, invisible)
import Swarm.Game.Entity hiding (empty)
import Swarm.Game.Location
import Swarm.Game.Log
import Swarm.Game.Util.Yaml
import Swarm.Language.Capability (Capability)
import Swarm.Language.Context qualified as Ctx
import Swarm.Language.Requirement (ReqCtx)
import Swarm.Language.Syntax (toDirection)
import Swarm.Language.Typed (Typed (..))
import Swarm.Language.Types (TCtx)
import Swarm.Language.Value as V
import Swarm.Game.Location
import Swarm.Game.Util.Yaml
import System.Clock (TimeSpec)

-- | A record that stores the information
Expand Down
2 changes: 1 addition & 1 deletion src/swarm-game/Swarm/Game/Scenario.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ import Swarm.Game.Scenario.Objective.Validation
import Swarm.Game.Scenario.RobotLookup
import Swarm.Game.Scenario.Style
import Swarm.Game.Scenario.WorldDescription
import Swarm.Game.Util.Yaml
import Swarm.Language.Pipeline (ProcessedTerm)
import Swarm.Util.Util (getDataFileNameSafe)
import Swarm.Game.Util.Yaml
import System.Directory (doesFileExist)
import System.FilePath ((<.>), (</>))
import Witch (from, into)
Expand Down
2 changes: 1 addition & 1 deletion src/swarm-game/Swarm/Game/Scenario/Objective.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Data.Aeson
import Data.Set qualified as Set
import Data.Text (Text)
import GHC.Generics (Generic)
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Scenario.Objective.Logic as L
import Swarm.Language.Pipeline (ProcessedTerm)
import Swarm.Game.Achievement.Definitions
import Swarm.Util.Util (reflow)

------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/swarm-game/Swarm/Game/Scenario/WorldDescription.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Data.Text (Text)
import Data.Text qualified as T
import Data.Yaml as Y
import Swarm.Game.Entity
import Swarm.Game.Location
import Swarm.Game.Scenario.Cell
import Swarm.Game.Scenario.RobotLookup
import Swarm.Game.Location
import Swarm.Game.Util.Yaml
import Witch (into)

Expand Down
10 changes: 6 additions & 4 deletions src/swarm-game/Swarm/Game/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ import Data.Text qualified as T (lines)
import Data.Text.IO qualified as T (readFile)
import Data.Time (getZonedTime)
import GHC.Generics (Generic)
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
import Swarm.Game.CESK (emptyStore, finalValue, initMachine)
import Swarm.Game.Entity
import Swarm.Game.Recipe (
Expand All @@ -160,11 +162,11 @@ import Swarm.Language.Syntax (Const, Term' (TText), allConst)
import Swarm.Language.Typed (Typed (Typed))
import Swarm.Language.Types
import Swarm.Language.Value (Value)
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
--import Swarm.Game.Scenario.Objective (Announcement)
import Swarm.Util.Util (getDataFileNameSafe, isRightOr, uniq, (<+=), (<<.=), (?))

-- import Swarm.Game.Scenario.Objective (Announcement)

import Swarm.Game.Location
import Swarm.Util.Util (getDataFileNameSafe, isRightOr, uniq, (<+=), (<<.=), (?))
import System.Clock qualified as Clock
import System.Random (StdGen, mkStdGen, randomRIO)
import Witch (into)
Expand Down
8 changes: 4 additions & 4 deletions src/swarm-game/Swarm/Game/Step.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ import Data.Text qualified as T
import Data.Time (getZonedTime)
import Data.Tuple (swap)
import Linear (zero)
import Linear.Affine (Affine(..))
import Linear.Affine (Affine (..))
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
import Swarm.Game.CESK
import Swarm.Game.Display
import Swarm.Game.Entity hiding (empty, lookup, singleton, union)
import Swarm.Game.Entity qualified as E
import Swarm.Game.Exception
import Swarm.Game.Location
import Swarm.Game.Recipe
import Swarm.Game.Robot
import Swarm.Game.Scenario.Objective qualified as OB
Expand All @@ -71,10 +74,7 @@ import Swarm.Language.Requirement qualified as R
import Swarm.Language.Syntax
import Swarm.Language.Typed (Typed (..))
import Swarm.Language.Value
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
import Swarm.Util.Util
import Swarm.Game.Location
import System.Clock (TimeSpec)
import System.Clock qualified
import System.Random (UniformRange, uniformR)
Expand Down
1 change: 1 addition & 0 deletions src/swarm-game/Swarm/Game/Terrain.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}

-- |
-- Module : Swarm.Game.Terrain
-- Copyright : Brent Yorgey
Expand Down
2 changes: 1 addition & 1 deletion src/swarm-game/Swarm/Game/World.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ import Data.Int (Int32)
import Data.Map.Strict qualified as M
import Data.Yaml (FromJSON, ToJSON)
import GHC.Generics (Generic)
import Swarm.Util.Util
import Swarm.Game.Location
import Swarm.Util.Util
import Prelude hiding (lookup)

------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/swarm-language/Swarm/Language/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import Data.Char qualified as C (toLower)
import Data.Data (Data)
import Data.Data.Lens (uniplate)
import Data.Hashable (Hashable)
import Data.Int (Int32)
import Data.List qualified as L (tail)
import Data.List.NonEmpty (NonEmpty)
import Data.List.NonEmpty qualified as NonEmpty
Expand All @@ -110,7 +111,6 @@ import Linear
import Swarm.Language.Types
import Swarm.Util.Util qualified as Util
import Witch.From (from)
import Data.Int (Int32)

------------------------------------------------------------
-- Directions
Expand Down
2 changes: 1 addition & 1 deletion src/swarm-user-interface/Swarm/TUI/Attr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import Data.Bifunctor (bimap)
import Data.Text (unpack)
import Data.Yaml
import Graphics.Vty qualified as V
import Swarm.Game.Display (Attribute(..))
import Swarm.Game.Display (Attribute (..))
import Witch (from)

toAttrName :: Attribute -> AttrName
Expand Down
12 changes: 6 additions & 6 deletions src/swarm-user-interface/Swarm/TUI/Controller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ import Data.Time (getZonedTime)
import Data.Vector qualified as V
import Graphics.Vty qualified as V
import Linear
import Linear.Affine (Affine(..))
import Linear.Affine (Affine (..))
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Achievement.Persistence
import Swarm.Game.CESK (cancel, emptyStore, initMachine)
import Swarm.Game.Entity hiding (empty)
import Swarm.Game.Location
import Swarm.Game.Robot
import Swarm.TUI.Model.Goal
import Swarm.TUI.View.Objective qualified as GR
import Swarm.Game.ScenarioInfo
import Swarm.Game.State
import Swarm.Game.Step (gameTick)
Expand All @@ -93,15 +94,14 @@ import Swarm.TUI.Controller.Util
import Swarm.TUI.Inventory.Sorting (cycleSortDirection, cycleSortOrder)
import Swarm.TUI.List
import Swarm.TUI.Model
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Achievement.Persistence
import Swarm.TUI.Model.Goal
import Swarm.TUI.Model.Name
import Swarm.TUI.Model.Repl
import Swarm.TUI.Model.StateUpdate
import Swarm.TUI.Model.UI
import Swarm.TUI.View (generateModal)
import Swarm.TUI.View.Objective qualified as GR
import Swarm.Util.Util hiding ((<<.=))
import Swarm.Game.Location
import Swarm.Version (NewReleaseFailure (..))
import System.Clock
import System.FilePath (splitDirectories)
Expand Down
2 changes: 1 addition & 1 deletion src/swarm-user-interface/Swarm/TUI/Model/Menu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Data.List.NonEmpty qualified as NE
import Data.Map qualified as M
import Data.Text (Text)
import Data.Vector qualified as V
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Entity as E
import Swarm.Game.ScenarioInfo (
ScenarioCollection,
Expand All @@ -24,7 +25,6 @@ import Swarm.Game.ScenarioInfo (
scenarioCollectionToList,
)
import Swarm.Game.State
import Swarm.Game.Achievement.Definitions
import Swarm.TUI.Model.Name
import Swarm.Util.Util
import System.FilePath (dropTrailingPathSeparator, splitPath, takeFileName)
Expand Down
10 changes: 5 additions & 5 deletions src/swarm-user-interface/Swarm/TUI/Model/StateUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import Data.Map qualified as M
import Data.Maybe (fromMaybe, isJust)
import Data.Text (Text)
import Data.Time (ZonedTime, getZonedTime)
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Achievement.Persistence
import Swarm.Game.Log (ErrorLevel (..), LogSource (ErrorTrace))
import Swarm.Game.Scenario (loadScenario, scenarioAttrs)
import Swarm.TUI.Model.Goal (emptyGoalDisplay)
import Swarm.Game.ScenarioInfo (
ScenarioInfo (..),
ScenarioInfoPair,
Expand All @@ -35,13 +37,11 @@ import Swarm.Game.ScenarioInfo (
_SISingle,
)
import Swarm.Game.State
import Swarm.Game.Util.Failure (prettyFailure)
import Swarm.TUI.Attr (swarmAttrMap)
import Swarm.TUI.Inventory.Sorting
import Swarm.TUI.Model
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Achievement.Persistence
import Swarm.Game.Util.Failure (prettyFailure)
import Swarm.TUI.Model.Goal (emptyGoalDisplay)
import Swarm.TUI.Model.Repl
import Swarm.TUI.Model.UI
import Swarm.TUI.View.CustomStyling (toAttrPair)
Expand Down
10 changes: 5 additions & 5 deletions src/swarm-user-interface/Swarm/TUI/Model/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ import Data.Map (Map)
import Data.Map qualified as M
import Data.Text (Text)
import Data.Text qualified as T
import Swarm.TUI.Model.Goal
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Achievement.Persistence
import Swarm.Game.ScenarioInfo (
ScenarioInfoPair,
)
import Swarm.Game.Util.Failure (SystemFailure)
import Swarm.Game.World qualified as W
import Swarm.TUI.Attr (swarmAttrMap)
import Swarm.TUI.Inventory.Sorting
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Achievement.Persistence
import Swarm.Game.Util.Failure (SystemFailure)
import Swarm.TUI.Model.Goal
import Swarm.TUI.Model.Menu
import Swarm.TUI.Model.Name
import Swarm.TUI.Model.Repl
Expand Down
6 changes: 3 additions & 3 deletions src/swarm-user-interface/Swarm/TUI/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,10 @@ import Network.Wai.Handler.Warp (Port)
import Swarm.Game.CESK (CESK (..))
import Swarm.Game.Display
import Swarm.Game.Entity as E
import Swarm.Game.Location
import Swarm.Game.Recipe
import Swarm.Game.Robot
import Swarm.Game.Scenario (scenarioAuthor, scenarioDescription, scenarioName, scenarioObjectives)
import Swarm.TUI.Model.Goal (goalsContent, hasAnythingToShow)
import Swarm.TUI.View.Objective qualified as GR
import Swarm.Game.ScenarioInfo (
ScenarioItem (..),
ScenarioStatus (..),
Expand All @@ -96,14 +95,15 @@ import Swarm.TUI.Attr
import Swarm.TUI.Border
import Swarm.TUI.Inventory.Sorting (renderSortMethod)
import Swarm.TUI.Model
import Swarm.TUI.Model.Goal (goalsContent, hasAnythingToShow)
import Swarm.TUI.Model.Repl
import Swarm.TUI.Model.UI
import Swarm.TUI.Panel
import Swarm.TUI.View.Achievement
import Swarm.TUI.View.CellDisplay
import Swarm.TUI.View.Objective qualified as GR
import Swarm.TUI.View.Util
import Swarm.Util.Util
import Swarm.Game.Location
import Swarm.Version (NewReleaseFailure (..))
import System.Clock (TimeSpec (..))
import Text.Printf
Expand Down
4 changes: 2 additions & 2 deletions src/swarm-user-interface/Swarm/TUI/View/Achievement.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import Control.Lens ((^.))
import Data.Map (Map)
import Data.Map qualified as M
import Data.Time.Format (defaultTimeLocale, formatTime)
import Swarm.TUI.Attr
import Swarm.TUI.Model
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
import Swarm.Game.Achievement.Description
import Swarm.TUI.Attr
import Swarm.TUI.Model
import Swarm.TUI.Model.UI
import Text.Wrap

Expand Down
Loading