From 9a72bc52a5f6c13044bb38f83b0ce29310664034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0ebek?= <44544735+xsebek@users.noreply.github.com> Date: Thu, 9 Jun 2022 00:32:12 +0200 Subject: [PATCH] Reformat codebase with Fourmolu (#370) Run ```bash fourmolu -i $(find . -name '*.hs') ``` --- bench/Benchmark.hs | 4 ++-- images/logo/MkLogo.hs | 12 ++++++------ src/Swarm/Game/Scenario.hs | 2 +- src/Swarm/Game/State.hs | 4 ++-- src/Swarm/TUI/View.hs | 10 +++++----- src/Swarm/Util/Yaml.hs | 2 +- test/Integration.hs | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bench/Benchmark.hs b/bench/Benchmark.hs index 1d0a6765..4c7f444e 100644 --- a/bench/Benchmark.hs +++ b/bench/Benchmark.hs @@ -15,7 +15,7 @@ import Linear.V2 (V2 (V2)) import Swarm.Game.CESK (emptyStore, initMachine) import Swarm.Game.Display (defaultRobotDisplay) import Swarm.Game.Robot (URobot, mkRobot) -import Swarm.Game.State (GameState, addURobot, creativeMode, classicGame0, world) +import Swarm.Game.State (GameState, addURobot, classicGame0, creativeMode, world) import Swarm.Game.Step (gameTick) import Swarm.Game.Terrain (TerrainType (DirtT)) import Swarm.Game.World (newWorld) @@ -78,7 +78,7 @@ initRobot prog loc = mkRobot (F.Const ()) Nothing "" [] north loc defaultRobotDi -- in a row starting at (0,0) and spreading east. mkGameState :: (V2 Int64 -> URobot) -> Int -> IO GameState mkGameState robotMaker numRobots = do - let robots = [robotMaker (V2 (fromIntegral x) 0) | x <- [0 .. numRobots -1]] + let robots = [robotMaker (V2 (fromIntegral x) 0) | x <- [0 .. numRobots - 1]] Right initState <- runExceptT classicGame0 execStateT (mapM addURobot robots) diff --git a/images/logo/MkLogo.hs b/images/logo/MkLogo.hs index d0c9a3b1..cbfbf1ae 100755 --- a/images/logo/MkLogo.hs +++ b/images/logo/MkLogo.hs @@ -12,14 +12,14 @@ chars = "<^>vT~@░ " replace :: Char -> IO Char replace ' ' = pick $ zip (replicate 8 0.005 ++ [1]) chars -replace _ = pick $ zip (replicate 4 0.2 ++ replicate 4 0.04 ++ [1]) chars +replace _ = pick $ zip (replicate 4 0.2 ++ replicate 4 0.04 ++ [1]) chars pick :: [(Double, a)] -> IO a pick es = do r <- randomRIO (0 :: Double, 1) return $ go r es - where - go _ [(_,a)] = a - go r ((p,a):es) - | r < p = a - | otherwise = go (r - p) es + where + go _ [(_, a)] = a + go r ((p, a) : es) + | r < p = a + | otherwise = go (r - p) es diff --git a/src/Swarm/Game/Scenario.hs b/src/Swarm/Game/Scenario.hs index 6d559f58..abf0fa5d 100644 --- a/src/Swarm/Game/Scenario.hs +++ b/src/Swarm/Game/Scenario.hs @@ -180,7 +180,7 @@ mkWorldFun pwd = E $ \em -> do Coords (ulr, ulc) = locToCoords (ul wd) arr <- - fmap (listArray ((ulr, ulc), (ulr + rs -1, ulc + cs -1))) + fmap (listArray ((ulr, ulc), (ulr + rs - 1, ulc + cs - 1))) . mapM toEntity . concat $ grid diff --git a/src/Swarm/Game/State.hs b/src/Swarm/Game/State.hs index 867e27af..37f62861 100644 --- a/src/Swarm/Game/State.hs +++ b/src/Swarm/Game/State.hs @@ -370,8 +370,8 @@ viewingRegion :: GameState -> (Int64, Int64) -> (W.Coords, W.Coords) viewingRegion g (w, h) = (W.Coords (rmin, cmin), W.Coords (rmax, cmax)) where V2 cx cy = g ^. viewCenter - (rmin, rmax) = over both (+ (- cy - h `div` 2)) (0, h -1) - (cmin, cmax) = over both (+ (cx - w `div` 2)) (0, w -1) + (rmin, rmax) = over both (+ (- cy - h `div` 2)) (0, h - 1) + (cmin, cmax) = over both (+ (cx - w `div` 2)) (0, w - 1) -- | Find out which robot is currently specified by the -- 'viewCenterRule', if any. diff --git a/src/Swarm/TUI/View.hs b/src/Swarm/TUI/View.hs index ab827d33..bad3d1eb 100644 --- a/src/Swarm/TUI/View.hs +++ b/src/Swarm/TUI/View.hs @@ -615,8 +615,8 @@ drawRecipe e inv (Recipe ins outs reqs time) = , fmtEntityName missing ingr -- name of the input , padLeft (Pad 1) $ -- a connecting line: ─────┬ hBorder - <+> ( joinableBorder (Edges (i /= 0) (i /= inLen -1) True False) -- ...maybe plus vert ext: │ - <=> if i /= inLen -1 + <+> ( joinableBorder (Edges (i /= 0) (i /= inLen - 1) True False) -- ...maybe plus vert ext: │ + <=> if i /= inLen - 1 then vLimit (subtract 1 . length . T.words $ ingr ^. entityName) vBorder else emptyWidget ) @@ -627,8 +627,8 @@ drawRecipe e inv (Recipe ins outs reqs time) = drawOut i (n, ingr) = hBox [ padRight (Pad 1) $ - ( joinableBorder (Edges (i /= 0) (i /= outLen -1) False True) - <=> if i /= outLen -1 + ( joinableBorder (Edges (i /= 0) (i /= outLen - 1) False True) + <=> if i /= outLen - 1 then vLimit (subtract 1 . length . T.words $ ingr ^. entityName) vBorder else emptyWidget ) @@ -676,7 +676,7 @@ drawRobotLog s = allMe = all ((== rn) . Just . view leRobotName) logEntries drawEntry i e = - (if i == n -1 && s ^. uiState . uiScrollToEnd then visible else id) + (if i == n - 1 && s ^. uiState . uiScrollToEnd then visible else id) . txtWrapWith indent2 $ (if allMe then e ^. leText else T.concat ["[", e ^. leRobotName, "] ", e ^. leText]) diff --git a/src/Swarm/Util/Yaml.hs b/src/Swarm/Util/Yaml.hs index f1fc3c93..30e253e8 100644 --- a/src/Swarm/Util/Yaml.hs +++ b/src/Swarm/Util/Yaml.hs @@ -79,7 +79,7 @@ class FromJSONE e a where parseJSONE = liftE . parseJSON parseJSONE' :: e -> Value -> Parser a - parseJSONE' e = ($e) . runE . parseJSONE + parseJSONE' e = ($ e) . runE . parseJSONE instance FromJSONE e Int diff --git a/test/Integration.hs b/test/Integration.hs index 4084cefb..bd7fe7d7 100644 --- a/test/Integration.hs +++ b/test/Integration.hs @@ -14,8 +14,8 @@ import Test.Tasty import Test.Tasty.HUnit import Witch -import Swarm.Game.Scenario import Swarm.Game.Entity +import Swarm.Game.Scenario import Swarm.Language.Pipeline (processTerm) import Swarm.Util.Yaml (decodeFileEitherE)