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

Enable HLint in CI #371

Merged
merged 4 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Make HLint happy
- remove unused pragmas
- remove some unnecessary parens
  • Loading branch information
xsebek committed Jun 8, 2022
commit 1b439f1c6b0702cfe4129d2b64ee08634413acf0
2 changes: 1 addition & 1 deletion src/Swarm/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ app =
{ appDraw = drawUI
, appChooseCursor = chooseCursor
, appHandleEvent = handleEvent
, appStartEvent = \s -> s <$ enablePasteMode
, appStartEvent = (<$ enablePasteMode)
, appAttrMap = const swarmAttrMap
}

Expand Down
1 change: 0 additions & 1 deletion src/Swarm/Game/CESK.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeOperators #-}

-- |
-- Module : Swarm.Game.CESK
Expand Down
9 changes: 3 additions & 6 deletions src/Swarm/Game/Entity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
Expand Down Expand Up @@ -327,9 +325,8 @@ buildEntityMap es =
instance FromJSON Entity where
parseJSON = withObject "Entity" $ \v ->
rehashEntity
<$> ( Entity
<$> pure 0
<*> v .: "display"
<$> ( Entity 0
<$> v .: "display"
<*> v .: "name"
<*> v .:? "plural"
<*> (map reflow <$> (v .: "description"))
Expand Down Expand Up @@ -599,4 +596,4 @@ union (Inventory cs1 byN1 h1) (Inventory cs2 byN2 h2) =
-- of the way each entity with count k contributes (k+1) times its
-- hash. So if the two inventories share an entity e, just adding their
-- hashes would mean e now contributes (k+2) times its hash.
common = IS.foldl' (+) 0 $ (IM.keysSet cs1) `IS.intersection` (IM.keysSet cs2)
common = IS.foldl' (+) 0 $ IM.keysSet cs1 `IS.intersection` IM.keysSet cs2
1 change: 0 additions & 1 deletion src/Swarm/Game/Recipe.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down
1 change: 0 additions & 1 deletion src/Swarm/Game/Robot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}

Expand Down
4 changes: 2 additions & 2 deletions src/Swarm/Game/Step.hs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ execConst c vs s k = do
let yieldName = e ^. entityYields
e' <- case yieldName of
Nothing -> return e
Just n -> (?e) <$> uses entityMap (lookupEntityName n)
Just n -> fromMaybe e <$> uses entityMap (lookupEntityName n)

robotInventory %= insert e'

Expand Down Expand Up @@ -1444,7 +1444,7 @@ evalCmp c v1 v2 = decideCmp c $ compareValues v1 v2
-- | Compare two values, returning an 'Ordering' if they can be
-- compared, or @Nothing@ if they cannot.
compareValues :: Has (Throw Exn) sig m => Value -> Value -> m Ordering
compareValues = \v1 -> case v1 of
compareValues v1 = case v1 of
VUnit -> \case VUnit -> return EQ; v2 -> incompatCmp VUnit v2
VInt n1 -> \case VInt n2 -> return (compare n1 n2); v2 -> incompatCmp v1 v2
VString t1 -> \case VString t2 -> return (compare t1 t2); v2 -> incompatCmp v1 v2
Expand Down
1 change: 0 additions & 1 deletion src/Swarm/Game/Terrain.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeApplications #-}

Expand Down
2 changes: 0 additions & 2 deletions src/Swarm/Game/World.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}

Expand Down
2 changes: 0 additions & 2 deletions src/Swarm/Language/Context.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}

Expand Down
2 changes: 0 additions & 2 deletions src/Swarm/Language/Elaborate.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE OverloadedStrings #-}

-- |
-- Module : Swarm.Language.Elaborate
-- Copyright : Brent Yorgey
Expand Down
2 changes: 1 addition & 1 deletion src/Swarm/Language/LSP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ handlers =
case mdoc of
Just vf@(VirtualFile _ version _rope) -> do
validateSwarmCode doc (Just version) (virtualFileText vf)
_ -> debug $ "No virtual file found for: " <> (from (show msg))
_ -> debug $ "No virtual file found for: " <> from (show msg)
]
2 changes: 0 additions & 2 deletions src/Swarm/Language/Parse.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}

-- |
-- Module : Swarm.Language.Parse
Expand Down
4 changes: 0 additions & 4 deletions src/Swarm/Language/Parse/QQ.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
{-# LANGUAGE TemplateHaskell #-}

-- |
-- Module : Swarm.Language.Parse.QQ
-- Copyright : Brent Yorgey
Expand Down
1 change: 0 additions & 1 deletion src/Swarm/Language/Pipeline.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}

-- |
-- Module : Swarm.Language.Pipeline
Expand Down
4 changes: 0 additions & 4 deletions src/Swarm/Language/Pipeline/QQ.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
{-# LANGUAGE TemplateHaskell #-}

-- |
-- Module : Swarm.Language.Pipeline.QQ
-- Copyright : Brent Yorgey
Expand Down
2 changes: 0 additions & 2 deletions src/Swarm/Language/Pretty.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}

Expand Down
3 changes: 1 addition & 2 deletions src/Swarm/Language/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE UndecidableInstances #-}

Expand Down Expand Up @@ -131,7 +130,7 @@ dirInfo d = case d of
-- e.g. DLeft becomes "left"
directionSyntax = toLower . T.tail . from . show $ d
cardinal v2 = DirInfo directionSyntax (Just v2) (const v2)
relative vf = DirInfo directionSyntax Nothing vf
relative = DirInfo directionSyntax Nothing

-- | The cardinal direction north = @V2 0 1@.
north :: V2 Int64
Expand Down
1 change: 0 additions & 1 deletion src/Swarm/Language/Typecheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

-- For 'Ord IntVar' instance
Expand Down
3 changes: 0 additions & 3 deletions src/Swarm/Language/Types.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
Expand All @@ -11,7 +9,6 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

-- for the Data IntVar instance
Expand Down
18 changes: 9 additions & 9 deletions src/Swarm/TUI/Border.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Brick
import Brick.Widgets.Border
import Control.Lens (makeLenses, to, (^.))
import qualified Graphics.Vty as V
import Data.Function ((&))

-- | Labels for a horizontal border, with optional left, middle, and
-- right labels.
Expand Down Expand Up @@ -113,11 +114,10 @@ borderWithLabels labels wrapped =
Widget (hSize wrapped) (vSize wrapped) $ do
c <- getContext

middleResult <-
render $
hLimit (c ^. availWidthL - 2) $
vLimit (c ^. availHeightL - 2) $
wrapped
middleResult <- wrapped
& vLimit (c ^. availHeightL - 2)
& hLimit (c ^. availWidthL - 2)
& render

let tl = joinableBorder (Edges False True False True)
tr = joinableBorder (Edges False True True False)
Expand All @@ -128,7 +128,7 @@ borderWithLabels labels wrapped =
middle = vBorder <+> Widget Fixed Fixed (return middleResult) <+> vBorder
total = top <=> middle <=> bottom

render $
hLimit (middleResult ^. imageL . to V.imageWidth + 2) $
vLimit (middleResult ^. imageL . to V.imageHeight + 2) $
total
total
& vLimit (middleResult ^. imageL . to V.imageHeight + 2)
& hLimit (middleResult ^. imageL . to V.imageWidth + 2)
& render
2 changes: 0 additions & 2 deletions src/Swarm/TUI/Controller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}

-- |
-- Module : Swarm.TUI.Controller
Expand Down
8 changes: 4 additions & 4 deletions src/Swarm/TUI/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ handleListEventWithSeparators ::
EventM n (BL.GenericList n t e)
handleListEventWithSeparators e isSep theList =
case e of
V.EvKey V.KUp [] -> return $ backward
V.EvKey (V.KChar 'k') [] -> return $ backward
V.EvKey V.KDown [] -> return $ forward
V.EvKey (V.KChar 'j') [] -> return $ forward
V.EvKey V.KUp [] -> return backward
V.EvKey (V.KChar 'k') [] -> return backward
V.EvKey V.KDown [] -> return forward
V.EvKey (V.KChar 'j') [] -> return forward
V.EvKey V.KHome [] ->
return $
listFindByStrategy fwdInclusive isItem $
Expand Down
2 changes: 1 addition & 1 deletion src/Swarm/TUI/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ drawNewGameMenuUI (l :| ls) =
. BL.renderList (const drawScenarioItem) True
$ l
]
, padLeft (Pad 5) (maybe (txt "") drawDescription $ snd <$> BL.listSelectedElement l)
, padLeft (Pad 5) (maybe (txt "") (drawDescription . snd) (BL.listSelectedElement l))
]
where
drawScenarioItem (SISingle s) = padRight Max . txt $ s ^. scenarioName
Expand Down
2 changes: 0 additions & 2 deletions src/Swarm/Util/Yaml.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableInstances #-}
Expand Down
2 changes: 1 addition & 1 deletion test/Unit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ prettyConst =
, testCase
"pairs #225 - nested pairs are printed right-associative"
( equalPretty "(1, 2, 3)" $
(TPair (TInt 1) (TPair (TInt 2) (TInt 3)))
TPair (TInt 1) (TPair (TInt 2) (TInt 3))
)
]
where
Expand Down