From ed63b3f63555a9bc1c23d201febf392320440d99 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 6 Sep 2023 20:39:40 +0000 Subject: [PATCH] Restyled by fourmolu --- src/Swarm/TUI/View/Attribute/Attr.hs | 10 +++++----- src/Swarm/Util/UnitInterval.hs | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Swarm/TUI/View/Attribute/Attr.hs b/src/Swarm/TUI/View/Attribute/Attr.hs index b20b34581..42427e06a 100644 --- a/src/Swarm/TUI/View/Attribute/Attr.hs +++ b/src/Swarm/TUI/View/Attribute/Attr.hs @@ -49,8 +49,6 @@ module Swarm.TUI.View.Attribute.Attr ( customEditFocusedAttr, ) where -import Data.List.NonEmpty (NonEmpty (..)) -import Data.List.NonEmpty qualified as NE import Brick import Brick.Forms import Brick.Widgets.Dialog @@ -58,11 +56,13 @@ import Brick.Widgets.Edit qualified as E import Brick.Widgets.List hiding (reverse) import Data.Bifunctor (bimap) import Data.Colour.Palette.BrewerSet +import Data.List.NonEmpty (NonEmpty (..)) +import Data.List.NonEmpty qualified as NE +import Data.Maybe (fromMaybe) import Data.Text (unpack) import Graphics.Vty qualified as V import Swarm.Game.Display (Attribute (..)) import Swarm.TUI.View.Attribute.Util -import Data.Maybe (fromMaybe) toAttrName :: Attribute -> AttrName toAttrName = \case @@ -149,9 +149,9 @@ activityMeterPrefix = attrName "activityMeter" activityMeterAttributes :: NonEmpty (AttrName, V.Attr) activityMeterAttributes = - NE.zip indices $ fromMaybe (pure $ bg V.black) $ NE.nonEmpty brewers + NE.zip indices $ fromMaybe (pure $ bg V.black) $ NE.nonEmpty brewers where - indices = NE.map ((activityMeterPrefix <>) . attrName . show) $ (0 :: Int) :| [1..] + indices = NE.map ((activityMeterPrefix <>) . attrName . show) $ (0 :: Int) :| [1 ..] brewers = map bgWithAutoForeground $ reverse $ brewerSet RdYlGn 7 meterAttributeNames :: NonEmpty AttrName diff --git a/src/Swarm/Util/UnitInterval.hs b/src/Swarm/Util/UnitInterval.hs index 80799e604..145157e3d 100644 --- a/src/Swarm/Util/UnitInterval.hs +++ b/src/Swarm/Util/UnitInterval.hs @@ -9,8 +9,8 @@ module Swarm.Util.UnitInterval ( safeIndex, ) where -import Prelude hiding ((!!)) import Data.List.NonEmpty (NonEmpty, (!!)) +import Prelude hiding ((!!)) newtype UnitInterval a = UnitInterval { getValue :: a @@ -27,10 +27,11 @@ mkInterval = UnitInterval . max 0 . min 1 -- -- one less than the length of 'meterAttributeNames' (i.e., a valid index). -- -- See also: 'Swarm.Util.indexWrapNonEmpty'. -safeIndex :: RealFrac a => +safeIndex :: + RealFrac a => -- | alpha UnitInterval a -> - NonEmpty b -> - b + NonEmpty b -> + b safeIndex (UnitInterval alpha) xs = xs !! floor (alpha * fromIntegral (length xs - 1))