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

Bump Fourmolu to 0.7 #563

Merged
merged 2 commits into from
Jul 13, 2022
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
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@
# GHC we're using.
weederVersion = "2.4.0";

# Fourmolu updates often formatting arbitrarily, and we want to
# Fourmolu updates often alter formatting arbitrarily, and we want to
# have more control over this.
fourmoluVersion = "0.6.0.0";
fourmoluVersion = "0.7.0.1";

forAllSupportedSystems = flake-utils.lib.eachSystem [
"x86_64-linux"
Expand Down
2 changes: 1 addition & 1 deletion primer-rel8/src/Primer/Database/Rel8/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Rel8 (
Result,
namesFromLabels,
)
import qualified Rel8 (
import Rel8 qualified (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because we're now using GHC2021, which enables ImportQualifiedPost. Running Fourmolu 0.6 on the command line doesn't apply this styling because it doesn't look for extensions in the cabal file.

TableSchema (..),
)

Expand Down
6 changes: 3 additions & 3 deletions primer-rel8/test/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ module TestUtils (
import Foreword

import Data.ByteString.Lazy.UTF8 as BL
import qualified Data.Map.Strict as Map
import Data.Map.Strict qualified as Map
import Data.String (String)
import Data.Text (unpack)
import Data.Typeable (typeOf)
import qualified Database.PostgreSQL.Simple.Options as Options
import Database.PostgreSQL.Simple.Options qualified as Options
import Database.Postgres.Temp (
DB,
DirectoryType (Temporary),
Expand Down Expand Up @@ -83,7 +83,7 @@ import Test.Tasty.HUnit (
assertBool,
assertFailure,
)
import qualified Test.Tasty.HUnit as HUnit
import Test.Tasty.HUnit qualified as HUnit

-- The PostgreSQL host, username, and password can be chosen
-- statically, but we need to choose the port dynamically in order to
Expand Down
2 changes: 1 addition & 1 deletion primer-rel8/test/Tests/QuerySessionId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Primer.Database (
import Primer.Database.Rel8.Rel8Db (
runRel8Db,
)
import qualified Primer.Database.Rel8.Schema as Schema (
import Primer.Database.Rel8.Schema qualified as Schema (
SessionRow (SessionRow, app, gitversion, name, uuid),
)
import Rel8 (lit)
Expand Down
10 changes: 6 additions & 4 deletions primer-service/exe-server/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import Primer.App (
App,
)
import Primer.Database (Version)
import qualified Primer.Database as Db (
import Primer.Database qualified as Db (
ServiceCfg (..),
serve,
)
Expand All @@ -55,7 +55,7 @@ import Primer.Examples (
import Primer.Server (
serve,
)
import qualified StmContainers.Map as StmMap
import StmContainers.Map qualified as StmMap
import System.Directory (withCurrentDirectory)
import System.Environment (lookupEnv)

Expand Down Expand Up @@ -168,7 +168,8 @@ run opts = case cmd opts of
when seedDb $ do
let env = Env initialSessions dbOpQueue ver
flip runPrimerIO env $
forM_ seedApps $ uncurry addSession
forM_ seedApps $
uncurry addSession
withCurrentDirectory root (serve initialSessions dbOpQueue ver port)
db <- maybe defaultDb pure dbFlag
runDb (Db.ServiceCfg dbOpQueue ver) db
Expand All @@ -179,7 +180,8 @@ main = execParser opts >>= run
opts =
info
(helper <*> cmds)
( fullDesc <> progDesc "A web service for Primer."
( fullDesc
<> progDesc "A web service for Primer."
<> header
"primer-service - A web service for Primer."
)
14 changes: 7 additions & 7 deletions primer-service/src/Primer/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import Control.Concurrent.STM (

import Data.OpenApi (OpenApi)
import Data.Streaming.Network.Internal (HostPreference (HostIPv4Only))
import qualified Data.Text.Lazy as LT (fromStrict)
import qualified Data.Text.Lazy.Encoding as LT (encodeUtf8)
import qualified Network.Wai as WAI
import Data.Text.Lazy qualified as LT (fromStrict)
import Data.Text.Lazy.Encoding qualified as LT (encodeUtf8)
import Network.Wai qualified as WAI
import Network.Wai.Handler.Warp (
defaultSettings,
setHost,
setPort,
)
import qualified Network.Wai.Handler.Warp as Warp (runSettings)
import Network.Wai.Handler.Warp qualified as Warp (runSettings)
import Optics ((%), (.~), (?~))
import Primer.API (
Env (..),
Expand All @@ -44,7 +44,7 @@ import Primer.API (
runPrimerIO,
variablesInScope,
)
import qualified Primer.API as API
import Primer.API qualified as API
import Primer.Action (
Action (Move),
ActionError (TypeError),
Expand Down Expand Up @@ -95,7 +95,7 @@ import Primer.Database (
Sessions,
Version,
)
import qualified Primer.Database as Database (
import Primer.Database qualified as Database (
Op,
)
import Primer.Eval (BetaReductionDetail (..), EvalDetail (..))
Expand Down Expand Up @@ -127,7 +127,7 @@ import Servant (
(:<|>) (..),
(:>),
)
import qualified Servant (serve)
import Servant qualified (serve)
import Servant.OpenApi (toOpenApi)
import Servant.OpenApi.OperationId (OpId)
import Servant.Server.StaticFiles (serveDirectoryWith)
Expand Down
4 changes: 2 additions & 2 deletions primer-service/src/Servant/OpenApi/OperationId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ instance
toOpenApi _ =
toOpenApi (Proxy @(Verb method status ctypes a))
& traversalVL allOperations % #operationId
?~ pack (symbolVal (Proxy @id))
?~ pack (symbolVal (Proxy @id))

-- | Similar to 'OperationId', but for Servant-provided convenience synonyms,
-- like 'Get' or 'Post'
Expand All @@ -71,4 +71,4 @@ instance (KnownSymbol id, HasOpenApi (verb ctypes a)) => HasOpenApi (OpId id ver
toOpenApi _ =
toOpenApi (Proxy @(verb ctypes a))
& traversalVL allOperations % #operationId
?~ pack (symbolVal (Proxy @id))
?~ pack (symbolVal (Proxy @id))
4 changes: 2 additions & 2 deletions primer-service/test/Tests/Pagination.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foreword
import Data.String (String)
import Data.Text (unpack)
import Data.UUID.V4 (nextRandom)
import qualified Database.PostgreSQL.Simple.Options as Options
import Database.PostgreSQL.Simple.Options qualified as Options
import Database.Postgres.Temp (
DB,
DirectoryType (Temporary),
Expand Down Expand Up @@ -63,7 +63,7 @@ import System.Process.Typed (
)
import Test.Tasty (TestTree)
import Test.Tasty.HUnit (testCaseSteps)
import qualified Test.Tasty.HUnit as HUnit
import Test.Tasty.HUnit qualified as HUnit

(@?=) :: (MonadIO m, Eq a, Show a) => a -> a -> m ()
x @?= y = liftIO $ x HUnit.@?= y
Expand Down
12 changes: 6 additions & 6 deletions primer/src/Primer/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ import Control.Monad.Writer (MonadWriter)
import Control.Monad.Zip (MonadZip)
import Data.Aeson (ToJSON)
import Data.Data (showConstr, toConstr)
import qualified Data.Generics.Uniplate.Data as U
import qualified Data.Map as Map
import qualified ListT (toList)
import Data.Generics.Uniplate.Data qualified as U
import Data.Map qualified as Map
import ListT qualified (toList)
import Primer.App (
App,
EditAppM,
Expand All @@ -84,7 +84,7 @@ import Primer.App (
runEditAppM,
runQueryAppM,
)
import qualified Primer.App as App
import Primer.App qualified as App
import Primer.Core (
ASTDef (..),
Expr,
Expand Down Expand Up @@ -120,7 +120,7 @@ import Primer.Database (
pageList,
safeMkSessionName,
)
import qualified Primer.Database as Database (
import Primer.Database qualified as Database (
Op (
Insert,
ListSessions,
Expand All @@ -135,7 +135,7 @@ import qualified Primer.Database as Database (
)
import Primer.Module (moduleDefsQualified, moduleName, moduleTypesQualified)
import Primer.Name (Name, unName)
import qualified StmContainers.Map as StmMap
import StmContainers.Map qualified as StmMap

-- | The API environment.
data Env = Env
Expand Down
10 changes: 5 additions & 5 deletions primer/src/Primer/Action.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import Control.Monad.Fresh (MonadFresh)
import Data.Aeson (Value)
import Data.Generics.Product (typed)
import Data.List (findIndex)
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import qualified Data.Text as T
import Data.Map.Strict qualified as Map
import Data.Set qualified as Set
import Data.Text qualified as T
import Optics (set, (%), (?~))
import Primer.Core (
ASTDef (..),
Expand Down Expand Up @@ -62,7 +62,7 @@ import Primer.Core (
valConName,
valConType,
)
import qualified Primer.Core as C
import Primer.Core qualified as C
import Primer.Core.DSL (
aPP,
ann,
Expand Down Expand Up @@ -111,7 +111,7 @@ import Primer.Typecheck (
maybeTypeOf,
synth,
)
import qualified Primer.Typecheck as TC
import Primer.Typecheck qualified as TC
import Primer.Zipper (
BindLoc' (..),
CaseBindZ,
Expand Down
10 changes: 6 additions & 4 deletions primer/src/Primer/Action/Available.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Primer.Action.Available (
import Foreword

import Data.Data (Data)
import qualified Data.List.NonEmpty as NE
import Data.List.NonEmpty qualified as NE
import Optics (
to,
(%),
Expand All @@ -30,7 +30,7 @@ import Primer.Action (
nameString,
uniquifyDefName,
)
import qualified Primer.Action.Priorities as P
import Primer.Action.Priorities qualified as P
import Primer.Core (
ASTDef (..),
Bind' (..),
Expand Down Expand Up @@ -317,7 +317,8 @@ basicActionsForExpr l defName expr = case expr of
Beginner -> NoFunctions
_ -> Everything
in actionWithInput (Code "x") "Use a variable" (P.useVar l) Primary $
ChooseVariable filterVars $ pure . ConstructVar
ChooseVariable filterVars $
pure . ConstructVar

-- If we have a useful type, offer the refine action, otherwise offer the
-- saturate action.
Expand All @@ -334,7 +335,8 @@ basicActionsForExpr l defName expr = case expr of
insertVariableSaturatedRefined :: forall a. ExprMeta -> ActionSpec Expr a
insertVariableSaturatedRefined m =
actionWithInput (Code "f $ ?") "Apply a function to arguments" (P.useFunction l) Primary $
ChooseVariable OnlyFunctions $ \name -> [if offerRefined m then InsertRefinedVar name else InsertSaturatedVar name]
ChooseVariable OnlyFunctions $
\name -> [if offerRefined m then InsertRefinedVar name else InsertSaturatedVar name]

annotateExpression :: forall a. ActionSpec Expr a
annotateExpression = action (Code ":") "Annotate this expression with a type" (P.annotateExpr l) Primary [ConstructAnn]
Expand Down
28 changes: 14 additions & 14 deletions primer/src/Primer/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ import Data.Generics.Uniplate.Zipper (
)
import Data.List (intersect, (\\))
import Data.List.Extra (anySame, disjoint, (!?))
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import Data.Map.Strict qualified as Map
import Data.Set qualified as Set
import Optics (
Field1 (_1),
Field2 (_2),
Expand Down Expand Up @@ -139,11 +139,11 @@ import Primer.Core (
_typeMetaLens,
)
import Primer.Core.DSL (create, emptyHole, tEmptyHole)
import qualified Primer.Core.DSL as DSL
import Primer.Core.DSL qualified as DSL
import Primer.Core.Transform (foldApp, renameVar, unfoldAPP, unfoldApp, unfoldTApp)
import Primer.Core.Utils (freeVars, regenerateExprIDs, regenerateTypeIDs, _freeTmVars, _freeTyVars, _freeVarsTy)
import Primer.Eval (EvalDetail, EvalError)
import qualified Primer.Eval as Eval
import Primer.Eval qualified as Eval
import Primer.EvalFull (Dir, EvalFullError (TimedOut), TerminationBound, evalFull)
import Primer.JSON
import Primer.Module (
Expand Down Expand Up @@ -624,20 +624,20 @@ applyProgAction prog mdefName = \case
updateRefsInTypes =
over
(traversed % #_TypeDefAST % #astTypeDefConstructors % traversed % #valConArgs % traversed)
$ transform $
over (#_TCon % _2) updateName
$ transform
$ over (#_TCon % _2) updateName
updateDefType =
over
#astDefType
$ transform $
over (#_TCon % _2) updateName
$ transform
$ over (#_TCon % _2) updateName
updateDefBody =
over
#astDefExpr
$ transform $
over typesInExpr $
transform $
over (#_TCon % _2) updateName
$ transform
$ over typesInExpr
$ transform
$ over (#_TCon % _2) updateName
updateName n = if n == old then new else n
RenameCon type_ old (unsafeMkGlobalName . (fmap unName (unModuleName (qualifiedModule type_)),) -> new) ->
editModuleSameSelectionCross (qualifiedModule type_) prog $ \(m, ms) -> do
Expand Down Expand Up @@ -685,8 +685,8 @@ applyProgAction prog mdefName = \case
% #valConArgs
% traversed
)
$ over _freeVarsTy $
\(_, v) -> TVar () $ updateName v
$ over _freeVarsTy
$ \(_, v) -> TVar () $ updateName v
updateName n = if n == old then new else n
AddCon type_ index (unsafeMkGlobalName . (fmap unName (unModuleName (qualifiedModule type_)),) -> con) ->
editModuleSameSelectionCross (qualifiedModule type_) prog $ \(m, ms) -> do
Expand Down
2 changes: 1 addition & 1 deletion primer/src/Primer/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module Primer.Builtins (

import Foreword

import qualified Data.Map as Map
import Data.Map qualified as Map
import Primer.Core (
ASTTypeDef (
ASTTypeDef,
Expand Down
2 changes: 1 addition & 1 deletion primer/src/Primer/Core/Transform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Foreword
import Control.Monad.Fresh (MonadFresh)
import Data.Data (Data)
import Data.Generics.Uniplate.Data (descendM)
import qualified Data.List.NonEmpty as NE
import Data.List.NonEmpty qualified as NE
import Optics (traverseOf)
import Primer.Core (
CaseBranch' (..),
Expand Down
4 changes: 2 additions & 2 deletions primer/src/Primer/Core/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import Foreword
import Control.Monad.Fresh (MonadFresh, fresh)
import Data.Data (Data)
import Data.Generics.Uniplate.Data (universe)
import qualified Data.Map.Strict as M
import qualified Data.Set as S
import Data.Map.Strict qualified as M
import Data.Set qualified as S
import Data.Set.Optics (setOf)
import Optics (
Fold,
Expand Down
8 changes: 4 additions & 4 deletions primer/src/Primer/Database.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ import Control.Monad.STM (atomically)
import Control.Monad.Trans (MonadTrans)
import Control.Monad.Writer (MonadWriter)
import Control.Monad.Zip (MonadZip)
import qualified Data.Text as Text (
import Data.Text qualified as Text (
strip,
take,
takeWhile,
)
import Data.UUID (UUID)
import qualified Data.UUID as UUID (toText)
import Data.UUID qualified as UUID (toText)
import Data.UUID.V4 (nextRandom)
import qualified ListT (toList)
import ListT qualified (toList)
import Optics (
(.~),
)
import Primer.App (App)
import Primer.JSON (CustomJSON (CustomJSON), ToJSON, VJSON)
import qualified StmContainers.Map as StmMap
import StmContainers.Map qualified as StmMap

-- | A Primer version.
--
Expand Down
Loading