Skip to content

Commit

Permalink
Restyled by fourmolu (#1758)
Browse files Browse the repository at this point in the history
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
restyled-io[bot] and restyled-commits authored Jan 31, 2024
1 parent d3167b6 commit 662a96e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/Swarm/TUI/Model/Goal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Swarm.TUI.Model.Goal where

import Brick.Focus
import Brick.Widgets.List qualified as BL
import Control.Lens (makeLenses, (^..), view)
import Control.Lens (makeLenses, view, (^..))
import Data.Aeson
import Data.List.NonEmpty (NonEmpty, nonEmpty)
import Data.List.NonEmpty qualified as NE
Expand Down
7 changes: 4 additions & 3 deletions src/swarm-engine/Swarm/Game/Scenario/Objective/WinCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- Utilities to check whether conditions are met for a game win/loss.
module Swarm.Game.Scenario.Objective.WinCheck where

import Control.Lens ((^.), (^..), view, andOf)
import Control.Lens (andOf, view, (^.), (^..))
import Data.Aeson (ToJSON)
import Data.BoolExpr qualified as BE
import Data.BoolExpr.Simplify qualified as Simplify
Expand All @@ -23,8 +23,9 @@ import Swarm.Game.Scenario.Objective.Logic as L

-- | We have "won" if all of the "unwinnable" or remaining "incomplete" objectives are "optional".
didWin :: ObjectiveCompletion -> Bool
didWin oc = and (oc ^.. incompleteObjectives . objectiveOptional)
&& and (oc ^.. unwinnableObjectives . objectiveOptional)
didWin oc =
and (oc ^.. incompleteObjectives . objectiveOptional)
&& and (oc ^.. unwinnableObjectives . objectiveOptional)

-- | We have "lost" if any of the "unwinnable" objectives are not "optional".
didLose :: ObjectiveCompletion -> Bool
Expand Down
63 changes: 31 additions & 32 deletions src/swarm-scenario/Swarm/Game/Scenario/Objective.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
-- |
-- SPDX-License-Identifier: BSD-3-Clause
-- Description: Goals of scenario
module Swarm.Game.Scenario.Objective
( -- * Scenario objectives
PrerequisiteConfig(..)
, Objective
, objectiveGoal
, objectiveTeaser
, objectiveCondition
, objectiveId
, objectiveOptional
, objectivePrerequisite
, objectiveHidden
, objectiveAchievement
, Announcement(..)
-- * Objective completion tracking

, ObjectiveCompletion
, initCompletion
, completedIDs
, incompleteObjectives
, completedObjectives
, unwinnableObjectives
, allObjectives
, addCompleted
, addUnwinnable
, addIncomplete
, extractIncomplete
)
where
module Swarm.Game.Scenario.Objective (
-- * Scenario objectives
PrerequisiteConfig (..),
Objective,
objectiveGoal,
objectiveTeaser,
objectiveCondition,
objectiveId,
objectiveOptional,
objectivePrerequisite,
objectiveHidden,
objectiveAchievement,
Announcement (..),

-- * Objective completion tracking
ObjectiveCompletion,
initCompletion,
completedIDs,
incompleteObjectives,
completedObjectives,
unwinnableObjectives,
allObjectives,
addCompleted,
addUnwinnable,
addIncomplete,
extractIncomplete,
)
where

import Control.Applicative ((<|>))
import Control.Lens hiding (from, (<.>))
Expand All @@ -47,7 +47,7 @@ import Swarm.Game.Scenario.Objective.Logic as L
import Swarm.Language.Pipeline (ProcessedTerm)
import Swarm.Language.Syntax (Syntax)
import Swarm.Language.Text.Markdown qualified as Markdown
import Swarm.Util.Lens (makeLensesNoSigs, makeLensesExcluding, concatFold)
import Swarm.Util.Lens (concatFold, makeLensesExcluding, makeLensesNoSigs)

------------------------------------------------------------
-- Scenario objectives
Expand Down Expand Up @@ -211,7 +211,7 @@ data ObjectiveCompletion = ObjectiveCompletion
}
deriving (Show, Generic, FromJSON, ToJSON)

makeLensesFor [ ("_completedIDs", "internalCompletedIDs") ] ''ObjectiveCompletion
makeLensesFor [("_completedIDs", "internalCompletedIDs")] ''ObjectiveCompletion
makeLensesExcluding ['_completedIDs] ''ObjectiveCompletion

-- | Initialize an objective completion tracking record from a list of
Expand Down Expand Up @@ -265,8 +265,7 @@ allObjectives = incompleteObjectives `concatFold` completedObjectives `concatFol
addCompleted :: Objective -> ObjectiveCompletion -> ObjectiveCompletion
addCompleted obj =
(completionBuckets . completed %~ (obj :))
.
(internalCompletedIDs %~ maybe id Set.insert (obj ^. objectiveId))
. (internalCompletedIDs %~ maybe id Set.insert (obj ^. objectiveId))

-- | Add an unwinnable objective to an 'ObjectiveCompletion' record,
-- being careful to maintain its internal invariants.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- Validity checking for 'Objective' prerequisites
module Swarm.Game.Scenario.Objective.Validation where

import Control.Lens ((^.), view)
import Control.Lens (view, (^.))
import Control.Monad (unless)
import Data.Foldable (for_, toList)
import Data.Graph (stronglyConnComp)
Expand Down

0 comments on commit 662a96e

Please sign in to comment.