diff --git a/flake.nix b/flake.nix index f688fe232..d84746fea 100644 --- a/flake.nix +++ b/flake.nix @@ -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" diff --git a/primer-rel8/src/Primer/Database/Rel8/Schema.hs b/primer-rel8/src/Primer/Database/Rel8/Schema.hs index 39d9b126a..1d0459e8f 100644 --- a/primer-rel8/src/Primer/Database/Rel8/Schema.hs +++ b/primer-rel8/src/Primer/Database/Rel8/Schema.hs @@ -22,7 +22,7 @@ import Rel8 ( Result, namesFromLabels, ) -import qualified Rel8 ( +import Rel8 qualified ( TableSchema (..), ) diff --git a/primer-rel8/test/TestUtils.hs b/primer-rel8/test/TestUtils.hs index 32924f6ef..5c15f10f6 100644 --- a/primer-rel8/test/TestUtils.hs +++ b/primer-rel8/test/TestUtils.hs @@ -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), @@ -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 diff --git a/primer-rel8/test/Tests/QuerySessionId.hs b/primer-rel8/test/Tests/QuerySessionId.hs index 84acfa9d0..070f4b741 100644 --- a/primer-rel8/test/Tests/QuerySessionId.hs +++ b/primer-rel8/test/Tests/QuerySessionId.hs @@ -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) diff --git a/primer-service/exe-server/Main.hs b/primer-service/exe-server/Main.hs index a2c0513cc..e63137909 100644 --- a/primer-service/exe-server/Main.hs +++ b/primer-service/exe-server/Main.hs @@ -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, ) @@ -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) @@ -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 @@ -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." ) diff --git a/primer-service/src/Primer/Server.hs b/primer-service/src/Primer/Server.hs index 6f19336bf..c17223890 100644 --- a/primer-service/src/Primer/Server.hs +++ b/primer-service/src/Primer/Server.hs @@ -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 (..), @@ -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), @@ -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 (..)) @@ -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) diff --git a/primer-service/src/Servant/OpenApi/OperationId.hs b/primer-service/src/Servant/OpenApi/OperationId.hs index 5b7fc6c08..56bcc2f42 100644 --- a/primer-service/src/Servant/OpenApi/OperationId.hs +++ b/primer-service/src/Servant/OpenApi/OperationId.hs @@ -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' @@ -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)) diff --git a/primer-service/test/Tests/Pagination.hs b/primer-service/test/Tests/Pagination.hs index e9f1ded80..daed925f1 100644 --- a/primer-service/test/Tests/Pagination.hs +++ b/primer-service/test/Tests/Pagination.hs @@ -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), @@ -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 diff --git a/primer/src/Primer/API.hs b/primer/src/Primer/API.hs index a0f8abeb8..890276ce6 100644 --- a/primer/src/Primer/API.hs +++ b/primer/src/Primer/API.hs @@ -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, @@ -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, @@ -120,7 +120,7 @@ import Primer.Database ( pageList, safeMkSessionName, ) -import qualified Primer.Database as Database ( +import Primer.Database qualified as Database ( Op ( Insert, ListSessions, @@ -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 diff --git a/primer/src/Primer/Action.hs b/primer/src/Primer/Action.hs index a49d2f089..823e25371 100644 --- a/primer/src/Primer/Action.hs +++ b/primer/src/Primer/Action.hs @@ -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 (..), @@ -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, @@ -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, diff --git a/primer/src/Primer/Action/Available.hs b/primer/src/Primer/Action/Available.hs index 135ac1310..b5adbb694 100644 --- a/primer/src/Primer/Action/Available.hs +++ b/primer/src/Primer/Action/Available.hs @@ -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, (%), @@ -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' (..), @@ -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. @@ -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] diff --git a/primer/src/Primer/App.hs b/primer/src/Primer/App.hs index b1a91c024..02c59d3cd 100644 --- a/primer/src/Primer/App.hs +++ b/primer/src/Primer/App.hs @@ -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), @@ -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 ( @@ -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 @@ -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 diff --git a/primer/src/Primer/Builtins.hs b/primer/src/Primer/Builtins.hs index 4bf1e235f..a7f5075d2 100644 --- a/primer/src/Primer/Builtins.hs +++ b/primer/src/Primer/Builtins.hs @@ -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, diff --git a/primer/src/Primer/Core/Transform.hs b/primer/src/Primer/Core/Transform.hs index e2aa78fb5..afb4f7585 100644 --- a/primer/src/Primer/Core/Transform.hs +++ b/primer/src/Primer/Core/Transform.hs @@ -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' (..), diff --git a/primer/src/Primer/Core/Utils.hs b/primer/src/Primer/Core/Utils.hs index 93f7a8582..4e48061b5 100644 --- a/primer/src/Primer/Core/Utils.hs +++ b/primer/src/Primer/Core/Utils.hs @@ -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, diff --git a/primer/src/Primer/Database.hs b/primer/src/Primer/Database.hs index 1f518111f..426ab5da3 100644 --- a/primer/src/Primer/Database.hs +++ b/primer/src/Primer/Database.hs @@ -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. -- diff --git a/primer/src/Primer/Eval.hs b/primer/src/Primer/Eval.hs index 1e4b7403a..87eaf76de 100644 --- a/primer/src/Primer/Eval.hs +++ b/primer/src/Primer/Eval.hs @@ -31,8 +31,8 @@ import Foreword import Control.Arrow ((***)) import Control.Monad.Fresh (MonadFresh) import Data.Generics.Product (position) -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), elemOf, diff --git a/primer/src/Primer/EvalFull.hs b/primer/src/Primer/EvalFull.hs index a036277d9..b321f8620 100644 --- a/primer/src/Primer/EvalFull.hs +++ b/primer/src/Primer/EvalFull.hs @@ -21,8 +21,8 @@ import Foreword import Control.Monad.Extra (untilJustM) import Control.Monad.Fresh (MonadFresh) -import qualified Data.Map as M -import qualified Data.Set as S +import Data.Map qualified as M +import Data.Set qualified as S import Data.Set.Optics (setOf) import Data.Tuple.Extra (thd3) import GHC.Err (error) diff --git a/primer/src/Primer/Examples.hs b/primer/src/Primer/Examples.hs index 8ba285b72..9adb35ecb 100644 --- a/primer/src/Primer/Examples.hs +++ b/primer/src/Primer/Examples.hs @@ -44,14 +44,14 @@ import Foreword hiding ( ) import Control.Monad.Fresh (MonadFresh) -import qualified Data.Map.Strict as Map +import Data.Map.Strict qualified as Map import Primer.App ( App, Prog (..), defaultProg, mkApp, ) -import qualified Primer.Builtins as B +import Primer.Builtins qualified as B import Primer.Core ( ASTDef (ASTDef), Def (DefAST), diff --git a/primer/src/Primer/Name.hs b/primer/src/Primer/Name.hs index b09ec5246..e61771ed1 100644 --- a/primer/src/Primer/Name.hs +++ b/primer/src/Primer/Name.hs @@ -9,9 +9,9 @@ module Primer.Name ( import Foreword import Control.Monad.Fresh (MonadFresh, fresh) -import qualified Data.Char as C +import Data.Char qualified as C import Data.Data (Data) -import qualified Data.Set as S +import Data.Set qualified as S import Data.String (String) import Numeric.Natural (Natural) import Primer.JSON diff --git a/primer/src/Primer/Name/Fresh.hs b/primer/src/Primer/Name/Fresh.hs index 5d0efaaac..6abcfa5d7 100644 --- a/primer/src/Primer/Name/Fresh.hs +++ b/primer/src/Primer/Name/Fresh.hs @@ -11,11 +11,11 @@ module Primer.Name.Fresh ( import Foreword import Control.Monad.Fresh (MonadFresh) -import qualified Data.Set as S +import Data.Set qualified as S import Primer.Core (Expr, LocalName (LocalName, unLocalName), Type) import Primer.Core.Utils (freeVars, freeVarsTy) import Primer.Name (Name, NameCounter, freshName) -import qualified Primer.Typecheck as TC +import Primer.Typecheck qualified as TC import Primer.Zipper ( ExprZ, TypeZ, diff --git a/primer/src/Primer/Primitives.hs b/primer/src/Primer/Primitives.hs index 1af67c40f..8ffab0f36 100644 --- a/primer/src/Primer/Primitives.hs +++ b/primer/src/Primer/Primitives.hs @@ -12,7 +12,7 @@ module Primer.Primitives ( import Foreword import Data.Bitraversable (bisequence) -import qualified Data.Map as M +import Data.Map qualified as M import Numeric.Natural (Natural) import Primer.Builtins ( cJust, @@ -217,7 +217,8 @@ allPrimDefs = if y == 0 then con cNothing `aPP` tcon tInt else - con cJust `aPP` tcon tInt + con cJust + `aPP` tcon tInt `app` int (x `div` y) xs -> Left $ PrimFunError name xs } @@ -232,7 +233,8 @@ allPrimDefs = if y == 0 then con cNothing `aPP` tcon tInt else - con cJust `aPP` tcon tInt + con cJust + `aPP` tcon tInt `app` int (x `mod` y) xs -> Left $ PrimFunError name xs } @@ -334,7 +336,8 @@ allPrimDefs = then con cNothing `aPP` tcon tNat else con cJust - `aPP` tcon tNat `app` nat (fromInteger x) + `aPP` tcon tNat + `app` nat (fromInteger x) xs -> Left $ PrimFunError name xs } ) diff --git a/primer/src/Primer/Questions.hs b/primer/src/Primer/Questions.hs index 141dbb43d..f25d436a0 100644 --- a/primer/src/Primer/Questions.hs +++ b/primer/src/Primer/Questions.hs @@ -15,8 +15,8 @@ module Primer.Questions ( import Foreword -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 Primer.Core ( DefMap, GVarName, diff --git a/primer/src/Primer/Refine.hs b/primer/src/Primer/Refine.hs index 0892a8ab5..b0bfc5b59 100644 --- a/primer/src/Primer/Refine.hs +++ b/primer/src/Primer/Refine.hs @@ -3,14 +3,14 @@ module Primer.Refine (refine, Inst (..)) where import Foreword import Control.Monad.Fresh (MonadFresh) -import qualified Data.Map as Map -import qualified Data.Set as Set +import Data.Map qualified as Map +import Data.Set qualified as Set import Primer.Core (TyVarName, Type' (TForall, TFun, TVar)) -import qualified Primer.Core as C +import Primer.Core qualified as C import Primer.Core.Utils (freshLocalName) import Primer.Name (NameCounter) import Primer.Subst (substTy, substTys) -import qualified Primer.Typecheck as TC +import Primer.Typecheck qualified as TC import Primer.Unification (InternalUnifyError, unify) import Primer.Zipper (bindersBelowTy, focus) diff --git a/primer/src/Primer/Typecheck.hs b/primer/src/Primer/Typecheck.hs index 3da80560b..a35954876 100644 --- a/primer/src/Primer/Typecheck.hs +++ b/primer/src/Primer/Typecheck.hs @@ -66,9 +66,9 @@ import Control.Monad.Fresh (MonadFresh (..)) import Control.Monad.NestedError (MonadNestedError (..)) import Data.Functor.Compose (Compose (Compose), getCompose) import Data.Generics.Product (HasType, position, typed) -import qualified Data.Map as M -import qualified Data.Map.Strict as Map -import qualified Data.Set as S +import Data.Map qualified as M +import Data.Map.Strict qualified as Map +import Data.Set qualified as S import Data.Tuple.Extra (fst3) import Optics (Lens', over, set, traverseOf, view, (%)) import Optics.Traversal (traversed) @@ -377,7 +377,8 @@ checkTypeDefs tds = do (notElem (baseName tc) $ map (unLocalName . fst) params) "Duplicate names in one tydef: between type-def-name and parameter-names" local (noSmartHoles . extendLocalCxtTys params) $ - mapM_ (checkKind KType <=< fakeMeta) $ concatMap valConArgs cons + mapM_ (checkKind KType <=< fakeMeta) $ + concatMap valConArgs cons -- We need metadata to use checkKind, but we don't care about the output, -- just a yes/no answer. In this case it is fine to put nonsense in the -- metadata as it won't be inspected. @@ -988,7 +989,9 @@ getGlobalNames = do ( \t def -> S.fromList $ (f t :) $ - map (f . valConName) $ maybe [] astTypeDefConstructors $ typeDefAST def + map (f . valConName) $ + maybe [] astTypeDefConstructors $ + typeDefAST def ) tyDefs pure $ S.union topLevel ctors diff --git a/primer/src/Primer/Unification.hs b/primer/src/Primer/Unification.hs index e170b6606..e509ff942 100644 --- a/primer/src/Primer/Unification.hs +++ b/primer/src/Primer/Unification.hs @@ -3,8 +3,8 @@ module Primer.Unification (InternalUnifyError (..), unify) where import Foreword import Control.Monad.Fresh (MonadFresh) -import qualified Data.Map as M -import qualified Data.Set as S +import Data.Map qualified as M +import Data.Set qualified as S import Optics (anyOf, getting, over, set) import Primer.Core ( ID, @@ -60,7 +60,9 @@ unify cxt unificationVars s t = do result <- runExceptT $ flip execStateT mempty $ - flip runReaderT initEnv $ unU $ unify' s t + flip runReaderT initEnv $ + unU $ + unify' s t case result of Left _err -> pure Nothing Right sb -> do diff --git a/primer/src/Primer/Zipper.hs b/primer/src/Primer/Zipper.hs index 8a142bf54..630626d5e 100644 --- a/primer/src/Primer/Zipper.hs +++ b/primer/src/Primer/Zipper.hs @@ -60,9 +60,9 @@ import Data.Generics.Uniplate.Zipper ( replaceHole, zipper, ) -import qualified Data.Generics.Uniplate.Zipper as Z +import Data.Generics.Uniplate.Zipper qualified as Z import Data.List as List (delete) -import qualified Data.Set as S +import Data.Set qualified as S import Optics ( filteredBy, ifolded, diff --git a/primer/src/Primer/ZipperCxt.hs b/primer/src/Primer/ZipperCxt.hs index 50bc24b77..e4bfeb6ef 100644 --- a/primer/src/Primer/ZipperCxt.hs +++ b/primer/src/Primer/ZipperCxt.hs @@ -11,7 +11,7 @@ module Primer.ZipperCxt ( import Foreword import Data.Generics.Product (Param (..), param, position) -import qualified Data.Set as Set +import Data.Set qualified as Set import Optics (set, view, (^.)) import Primer.Core ( Bind' (..), diff --git a/primer/test/Gen/Core/Raw.hs b/primer/test/Gen/Core/Raw.hs index fd0d3fd0c..fbb98a080 100644 --- a/primer/test/Gen/Core/Raw.hs +++ b/primer/test/Gen/Core/Raw.hs @@ -21,8 +21,8 @@ module Gen.Core.Raw ( import Foreword import Hedgehog hiding (Var, check) -import qualified Hedgehog.Gen as Gen -import qualified Hedgehog.Range as Range +import Hedgehog.Gen qualified as Gen +import Hedgehog.Range qualified as Range import Primer.Core ( Bind' (Bind), CaseBranch' (CaseBranch), diff --git a/primer/test/Gen/Core/Typed.hs b/primer/test/Gen/Core/Typed.hs index 556199862..35ec35522 100644 --- a/primer/test/Gen/Core/Typed.hs +++ b/primer/test/Gen/Core/Typed.hs @@ -31,16 +31,16 @@ import Foreword import Control.Monad.Fresh (MonadFresh, fresh) import Control.Monad.Morph (hoist) import Control.Monad.Reader (mapReaderT) -import qualified Data.Map as M +import Data.Map qualified as M import Gen.Core.Raw (genLVarName, genModuleName, genName, genTyVarName) import Hedgehog ( GenT, MonadGen, PropertyT, ) -import qualified Hedgehog.Gen as Gen +import Hedgehog.Gen qualified as Gen import Hedgehog.Internal.Property (forAllT) -import qualified Hedgehog.Range as Range +import Hedgehog.Range qualified as Range import Primer.Core ( ASTTypeDef (..), Bind' (Bind), @@ -175,12 +175,14 @@ freshTyConNameForCxt = qualifyName <$> genModuleName <*> freshNameForCxt genLVarNameAvoiding :: [TypeG] -> GenT WT LVarName genLVarNameAvoiding ty = (\vs -> freshen (foldMap freeVarsTy ty <> foldMap freeVarsTy vs) 0) - <$> asks localTmVars <*> genLVarName + <$> asks localTmVars + <*> genLVarName genTyVarNameAvoiding :: TypeG -> GenT WT TyVarName genTyVarNameAvoiding ty = (\vs -> freshen (freeVarsTy ty <> foldMap freeVarsTy vs) 0) - <$> asks localTmVars <*> genTyVarName + <$> asks localTmVars + <*> genTyVarName freshen :: Set (LocalName k') -> Int -> LocalName k -> LocalName k freshen fvs i n = diff --git a/primer/test/TestUtils.hs b/primer/test/TestUtils.hs index d2e223633..83d3dd429 100644 --- a/primer/test/TestUtils.hs +++ b/primer/test/TestUtils.hs @@ -30,7 +30,7 @@ import Control.Monad.Fresh (MonadFresh) import Data.Coerce (coerce) import Data.String (String, fromString) import Data.Typeable (typeOf) -import qualified Hedgehog as H +import Hedgehog qualified as H import Optics (over, set, view) import Primer.API ( Env (..), @@ -70,14 +70,14 @@ import Primer.Database ( ) import Primer.Name (Name (unName)) import Primer.Primitives (allPrimDefs) -import qualified StmContainers.Map as StmMap -import qualified Test.Tasty.Discover as TD +import StmContainers.Map qualified as StmMap +import Test.Tasty.Discover qualified as TD import Test.Tasty.HUnit ( assertBool, assertFailure, ) -import qualified Test.Tasty.HUnit as HUnit -import qualified Test.Tasty.Hedgehog as TH +import Test.Tasty.HUnit qualified as HUnit +import Test.Tasty.Hedgehog qualified as TH withPrimDefs :: MonadFresh ID m => (Map GVarName PrimDef -> m a) -> m a withPrimDefs f = do diff --git a/primer/test/Tests/Action/Available.hs b/primer/test/Tests/Action/Available.hs index f2a6b4a17..a6b992631 100644 --- a/primer/test/Tests/Action/Available.hs +++ b/primer/test/Tests/Action/Available.hs @@ -2,10 +2,10 @@ module Tests.Action.Available where import Foreword -import qualified Data.ByteString.Lazy.Char8 as BS +import Data.ByteString.Lazy.Char8 qualified as BS import Data.List.Extra (enumerate) -import qualified Data.Text as T -import qualified Data.Text.Lazy as TL +import Data.Text qualified as T +import Data.Text.Lazy qualified as TL import GHC.Err (error) import Optics (toListOf, (%)) import Primer.Action (ActionName (..), OfferedAction (name)) diff --git a/primer/test/Tests/Action/Prog.hs b/primer/test/Tests/Action/Prog.hs index 933f30205..f627f9479 100644 --- a/primer/test/Tests/Action/Prog.hs +++ b/primer/test/Tests/Action/Prog.hs @@ -7,7 +7,7 @@ import Foreword import Control.Monad.Fresh import Data.Generics.Uniplate.Data (transformBi) import Data.List.Extra (anySame) -import qualified Data.Map.Strict as Map +import Data.Map.Strict qualified as Map import Optics import Primer.Action ( Action ( @@ -122,7 +122,7 @@ import Primer.Typecheck (SmartHoles (NoSmartHoles, SmartHoles), TypeError (Unkno import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, (@=?), (@?=)) import TestM (TestM, evalTestM) import TestUtils (constructCon, constructTCon, zeroIDs, zeroTypeIDs) -import qualified TestUtils +import TestUtils qualified import Tests.Typecheck (checkProgWellFormed) import Prelude (error) @@ -199,7 +199,8 @@ unit_rename_def_referenced = , BodyAction [ConstructVar $ globalVarRef "other"] , renameDef "other" "foo" ] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do assertNothing (lookupDef' "other" prog') assertJust (lookupDef' "foo" prog') assertJust (lookupDef' "main" prog') @@ -213,7 +214,8 @@ unit_rename_def_recursive = , BodyAction [ConstructVar $ globalVarRef "main"] , renameDef "main" "foo" ] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do assertNothing (lookupDef' "main" prog') assertJust (lookupDef' "foo" prog') fmap (forgetIDs . astDefExpr) (defAST =<< lookupDef' "foo" prog') @?= Just (Var () $ globalVarRef "foo") @@ -455,7 +457,8 @@ unit_create_typedef_8 = , astTypeDefNameHints = [] } in progActionTest defaultEmptyProg [AddTypeDef (tcn "T") td] $ - expectSuccess $ \_ prog' -> Map.elems (foldMap moduleTypes (progModules prog')) @?= [TypeDefAST td] + expectSuccess $ + \_ prog' -> Map.elems (foldMap moduleTypes (progModules prog')) @?= [TypeDefAST td] -- Allow clash between type name and constructor name across types unit_create_typedef_9 :: Assertion @@ -473,7 +476,8 @@ unit_create_typedef_9 = , astTypeDefNameHints = [] } in progActionTest defaultEmptyProg [AddTypeDef (tcn "T") td1, AddTypeDef (tcn "C") td2] $ - expectSuccess $ \_ prog' -> Map.elems (foldMap moduleTypes (progModules prog')) @?= [TypeDefAST td2, TypeDefAST td1] + expectSuccess $ + \_ prog' -> Map.elems (foldMap moduleTypes (progModules prog')) @?= [TypeDefAST td2, TypeDefAST td1] unit_construct_arrow_in_sig :: Assertion unit_construct_arrow_in_sig = @@ -826,7 +830,8 @@ unit_RenameType = ] ) [RenameType tT "T'"] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do -- The type is available under its new name td <- findTypeDef (tcn "T'") prog' -- The recursive reference to T is renamed also @@ -836,7 +841,9 @@ unit_RenameType = ] -- The old name does not refer to anything assertBool "Expected the old name to be out of scope" $ - not $ Map.member (tcn "T") $ foldMap moduleTypesQualified (progAllModules prog') + not $ + Map.member (tcn "T") $ + foldMap moduleTypesQualified (progAllModules prog') def <- findDef (gvn "def") prog' forgetIDs (astDefExpr def) @?= forgetIDs @@ -861,7 +868,9 @@ unit_RenameCon = hole ( hole $ case_ - ( con cA `aPP` tEmptyHole `aPP` tEmptyHole + ( con cA + `aPP` tEmptyHole + `aPP` tEmptyHole `app` con (vcn "True") `app` con (vcn "True") `app` con (vcn "True") @@ -874,7 +883,8 @@ unit_RenameCon = ] ) [RenameCon tT cA "A'"] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do td <- findTypeDef tT prog' astTypeDefConstructors td @?= [ ValCon (vcn "A'") [TCon () (tcn "Bool"), TCon () (tcn "Bool"), TCon () (tcn "Bool")] @@ -887,7 +897,9 @@ unit_RenameCon = hole ( hole $ case_ - ( con (vcn "A'") `aPP` tEmptyHole `aPP` tEmptyHole + ( con (vcn "A'") + `aPP` tEmptyHole + `aPP` tEmptyHole `app` con (vcn "True") `app` con (vcn "True") `app` con (vcn "True") @@ -920,7 +932,8 @@ unit_RenameTypeParam = progActionTest (defaultProgEditableTypeDefs $ pure []) [RenameTypeParam tT "b" "b'"] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do td <- findTypeDef tT prog' astTypeDefParameters td @?= [("a", KType), ("b'", KType)] astTypeDefConstructors td @@ -951,7 +964,8 @@ unit_AddCon = ] ) [AddCon tT 1 "C"] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do td <- findTypeDef tT prog' astTypeDefConstructors td @?= [ ValCon cA [TCon () (tcn "Bool"), TCon () (tcn "Bool"), TCon () (tcn "Bool")] @@ -975,14 +989,17 @@ unit_SetConFieldType = progActionTest ( defaultProgEditableTypeDefs . sequence . pure $ do x <- - con cA `aPP` tEmptyHole `aPP` tEmptyHole + con cA + `aPP` tEmptyHole + `aPP` tEmptyHole `app` con (vcn "True") `app` con (vcn "True") `app` con (vcn "True") astDef "def" x <$> tEmptyHole ) [SetConFieldType tT cA 1 $ TCon () (tcn "Int")] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do td <- findTypeDef tT prog' astTypeDefConstructors td @?= [ ValCon cA [TCon () (tcn "Bool"), TCon () (tcn "Int"), TCon () (tcn "Bool")] @@ -992,7 +1009,9 @@ unit_SetConFieldType = forgetIDs (astDefExpr def) @?= forgetIDs ( create' $ - con cA `aPP` tEmptyHole `aPP` tEmptyHole + con cA + `aPP` tEmptyHole + `aPP` tEmptyHole `app` con (vcn "True") `app` hole (con (vcn "True")) `app` con (vcn "True") @@ -1008,7 +1027,8 @@ unit_SetConFieldType_partial_app = ] ) [SetConFieldType tT cA 1 $ TCon () (tcn "Int")] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do def <- findDef (gvn "def") prog' forgetIDs (astDefExpr def) @?= forgetIDs @@ -1035,7 +1055,8 @@ unit_SetConFieldType_case = ] ) [SetConFieldType tT cA 1 $ TCon () (tcn "Int")] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do def <- findDef (gvn "def") prog' forgetIDs (astDefExpr def) @?= forgetIDs @@ -1068,7 +1089,8 @@ unit_SetConFieldType_shadow = ] ) [SetConFieldType tT cA 1 $ TCon () (tcn "Int")] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do def <- findDef (gvn "def") prog' forgetIDs (astDefExpr def) @?= forgetIDs @@ -1090,7 +1112,9 @@ unit_AddConField = ( defaultProgEditableTypeDefs $ do x <- case_ - ( con cA `aPP` tEmptyHole `aPP` tEmptyHole + ( con cA + `aPP` tEmptyHole + `aPP` tEmptyHole `app` con (vcn "True") `app` con (vcn "True") `app` con (vcn "True") @@ -1103,7 +1127,8 @@ unit_AddConField = ] ) [AddConField tT cA 1 $ TCon () (tcn "Int")] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do td <- findTypeDef tT prog' astTypeDefConstructors td @?= [ ValCon cA [TCon () (tcn "Bool"), TCon () (tcn "Int"), TCon () (tcn "Bool"), TCon () (tcn "Bool")] @@ -1114,7 +1139,9 @@ unit_AddConField = @?= forgetIDs ( create' $ case_ - ( con cA `aPP` tEmptyHole `aPP` tEmptyHole + ( con cA + `aPP` tEmptyHole + `aPP` tEmptyHole `app` con (vcn "True") `app` emptyHole `app` con (vcn "True") @@ -1135,12 +1162,14 @@ unit_AddConField_partial_app = ] ) [AddConField tT cA 2 $ TCon () (tcn "Int")] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do def <- findDef (gvn "def") prog' forgetIDs (astDefExpr def) @?= forgetIDs ( create' $ - hole $ con cA `app` con (vcn "True") + hole $ + con cA `app` con (vcn "True") ) unit_AddConField_partial_app_end :: Assertion @@ -1153,7 +1182,8 @@ unit_AddConField_partial_app_end = ] ) [AddConField tT cA 1 $ TCon () (tcn "Int")] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do td <- findTypeDef tT prog' astTypeDefConstructors td @?= [ ValCon cA [TCon () (tcn "Bool"), TCon () (tcn "Int"), TCon () (tcn "Bool"), TCon () (tcn "Bool")] @@ -1184,7 +1214,8 @@ unit_AddConField_case_ann = ] ) [AddConField tT cA 2 $ TCon () (tcn "Int")] - $ expectSuccess $ \_ prog' -> do + $ expectSuccess + $ \_ prog' -> do def <- findDef (gvn "def") prog' forgetIDs (astDefExpr def) @?= forgetIDs @@ -1247,9 +1278,9 @@ defaultEmptyProg = do } } & #progModules - % _head - % #moduleDefs - .~ Map.fromList [("main", DefAST mainDef), ("other", DefAST otherDef)] + % _head + % #moduleDefs + .~ Map.fromList [("main", DefAST mainDef), ("other", DefAST otherDef)] unit_good_defaultEmptyProg :: Assertion unit_good_defaultEmptyProg = checkProgWellFormed defaultEmptyProg @@ -1271,7 +1302,8 @@ defaultFullProg = do renamedTypes = foldOf (folded % #moduleTypes) renamed renamedDefs = foldOf (folded % #moduleDefs) renamed pure $ - p & #progModules % _head % #moduleTypes %~ (renamedTypes <>) + p + & #progModules % _head % #moduleTypes %~ (renamedTypes <>) & #progModules % _head % #moduleDefs %~ (renamedDefs <>) findTypeDef :: TyConName -> Prog -> IO ASTTypeDef @@ -1456,7 +1488,8 @@ unit_cross_module_actions = -- NB: CopyPasteSig relies on SmartHoles to fix any introduced inconsistencies barTy <- gets $ - fmap defType . flip findGlobalByName (qualifyName (ModuleName ["AnotherModule"]) "bar") + fmap defType + . flip findGlobalByName (qualifyName (ModuleName ["AnotherModule"]) "bar") . appProg let srcId = case barTy of Just (TFun _ src _) -> getID src diff --git a/primer/test/Tests/App.hs b/primer/test/Tests/App.hs index 2119c33dd..d0e4327b6 100644 --- a/primer/test/Tests/App.hs +++ b/primer/test/Tests/App.hs @@ -20,7 +20,7 @@ import Primer.App ( import Primer.Core ( ID, ) -import qualified Primer.Examples as Examples +import Primer.Examples qualified as Examples import Primer.Name ( NameCounter, ) diff --git a/primer/test/Tests/Database.hs b/primer/test/Tests/Database.hs index 136b63b51..ca2e7ad99 100644 --- a/primer/test/Tests/Database.hs +++ b/primer/test/Tests/Database.hs @@ -2,7 +2,7 @@ module Tests.Database where import Foreword -import qualified Data.Text as Text +import Data.Text qualified as Text import Primer.Database ( defaultSessionName, fromSessionName, diff --git a/primer/test/Tests/Eval.hs b/primer/test/Tests/Eval.hs index b9d27c8c1..a335017b2 100644 --- a/primer/test/Tests/Eval.hs +++ b/primer/test/Tests/Eval.hs @@ -2,8 +2,8 @@ module Tests.Eval where import Foreword -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 ((^.)) import Primer.App ( EvalReq (EvalReq, evalReqExpr, evalReqRedex), @@ -580,7 +580,8 @@ unit_tryReduce_case_name_clash = do result = runTryReduce mempty mempty (expr, i) expectedResult = create' $ - let_ "x0" emptyHole $ let_ "y" (lvar "x") emptyHole + let_ "x0" emptyHole $ + let_ "y" (lvar "x") emptyHole case result of Right (expr', CaseReduction detail) -> do expr' ~= expectedResult @@ -625,7 +626,9 @@ unit_tryReduce_prim = do let ((expr, expectedResult, globals), i) = create . withPrimDefs $ \m -> (,,) - <$> gvar (primitiveGVar "eqChar") `app` char 'a' `app` char 'a' + <$> gvar (primitiveGVar "eqChar") + `app` char 'a' + `app` char 'a' <*> con cTrue <*> pure m result = runTryReduce (DefPrim <$> globals) mempty (expr, i) @@ -644,7 +647,8 @@ unit_tryReduce_prim_fail_unsaturated = do let ((expr, globals), i) = create . withPrimDefs $ \m -> (,) - <$> gvar (primitiveGVar "eqChar") `app` char 'a' + <$> gvar (primitiveGVar "eqChar") + `app` char 'a' <*> pure m result = runTryReduce (DefPrim <$> globals) mempty (expr, i) result @?= Left NotRedex @@ -654,7 +658,9 @@ unit_tryReduce_prim_fail_unreduced_args = do let ((expr, globals), i) = create . withPrimDefs $ \m -> (,) - <$> gvar (primitiveGVar "eqChar") `app` char 'a' `app` (gvar (primitiveGVar "toUpper") `app` char 'a') + <$> gvar (primitiveGVar "eqChar") + `app` char 'a' + `app` (gvar (primitiveGVar "toUpper") `app` char 'a') <*> pure m result = runTryReduce (DefPrim <$> globals) mempty (expr, i) result @?= Left NotRedex @@ -916,13 +922,15 @@ unit_redexes_let_capture :: Assertion unit_redexes_let_capture = -- We should maybe rename the lambda, see https://github.com/hackworthltd/primer/issues/509 assertBool "Cannot inline the variable, as would cause capture" $ - Set.null $ redexesOf (let_ "x" (lvar "y") $ lam "y" $ lvar "x") + Set.null $ + redexesOf (let_ "x" (lvar "y") $ lam "y" $ lvar "x") unit_redexes_lettype_capture :: Assertion unit_redexes_lettype_capture = -- We should maybe rename the forall, see https://github.com/hackworthltd/primer/issues/509 assertBool "Cannot inline the variable, as would cause capture" $ - Set.null $ redexesOf (letType "x" (tvar "y") (emptyHole `ann` tforall "y" KType (tvar "x"))) + Set.null $ + redexesOf (letType "x" (tvar "y") (emptyHole `ann` tforall "y" KType (tvar "x"))) unit_redexes_letrec_1 :: Assertion unit_redexes_letrec_1 = @@ -1035,7 +1043,7 @@ unit_redexes_prim_ann = expr = gvar (primitiveGVar "toUpper") `ann` (tcon tChar `tfun` tcon tChar) - `app` (char 'a' `ann` tcon tChar) + `app` (char 'a' `ann` tcon tChar) -- Test that handleEvalRequest will reduce imported terms unit_eval_modules :: Assertion diff --git a/primer/test/Tests/EvalFull.hs b/primer/test/Tests/EvalFull.hs index e0450710e..efb22e877 100644 --- a/primer/test/Tests/EvalFull.hs +++ b/primer/test/Tests/EvalFull.hs @@ -4,16 +4,16 @@ import Foreword hiding (unlines) import Data.Generics.Uniplate.Data (universe) import Data.List (span, (\\)) -import qualified Data.List.NonEmpty as NE -import qualified Data.Map as M -import qualified Data.Map as Map -import qualified Data.Set as S +import Data.List.NonEmpty qualified as NE +import Data.Map qualified as M +import Data.Map qualified as Map +import Data.Set qualified as S import Data.String (unlines) import Gen.Core.Typed (WT, forAllT, genChk, genSyn, genWTType, isolateWT, propertyWT) import Hedgehog hiding (Property, Var, check, property, test, withDiscards, withTests) -import qualified Hedgehog.Gen as Gen +import Hedgehog.Gen qualified as Gen import Hedgehog.Internal.Property (LabelName (unLabelName)) -import qualified Hedgehog.Range as Range +import Hedgehog.Range qualified as Range import Optics import Primer.App ( EvalFullReq (EvalFullReq, evalFullCxtDir, evalFullMaxSteps, evalFullReqExpr), @@ -47,7 +47,7 @@ import Primer.Core.Utils ( generateIDs, ) import Primer.EvalFull -import qualified Primer.Examples as Examples ( +import Primer.Examples qualified as Examples ( even, map, map', @@ -553,7 +553,8 @@ unit_type_preservation_BETA_regression = foo = qualifyName (ModuleName ["M"]) "foo" fooTy = TForall () "d" KType $ TCon () tNat tmp ty e = case runTypecheckTestMWithPrims NoSmartHoles $ - local (extendGlobalCxt [(foo, fooTy)]) $ check ty e of + local (extendGlobalCxt [(foo, fooTy)]) $ + check ty e of Left err -> assertFailure $ show err Right _ -> pure () in do @@ -663,13 +664,15 @@ unit_regression_self_capture_let_let = do let e = lAM "y" $ let_ "x" (emptyHole `ann` tvar "y") $ - let_ "y" (emptyHole `ann` tvar "y") $ lvar "y" + let_ "y" (emptyHole `ann` tvar "y") $ + lvar "y" z = "a10" f = lAM "y" $ let_ "x" (emptyHole `ann` tvar "y") $ let_ z (emptyHole `ann` tvar "y") $ - let_ "y" (lvar z) $ lvar "y" + let_ "y" (lvar z) $ + lvar "y" (e', i) = create e ev n = evalFullTest i mempty mempty n Chk e' x ~ y = x <~==> Left (TimedOut (create' y)) @@ -757,14 +760,14 @@ tasty_prim_hex_nat = withTests 20 . property $ do ) ] <*> (con cJust `aPP` tcon tNat) - `app` ne + `app` ne <*> pure (DefPrim <$> globals) else create . withPrimDefs $ \globals -> (,,) <$> gvar (primitiveGVar "natToHex") - `app` ne + `app` ne <*> con cNothing - `aPP` tcon tChar + `aPP` tcon tChar <*> pure (DefPrim <$> globals) s = evalFullTest maxID builtinTypes gs 7 Syn e over evalResultExpr zeroIDs s === Right (zeroIDs r) @@ -791,7 +794,7 @@ unit_prim_char_partial = create . withPrimDefs $ \globals -> (,) <$> gvar (primitiveGVar "eqChar") - `app` char 'a' + `app` char 'a' <*> pure (DefPrim <$> globals) s = evalFullTest maxID mempty gs 1 Syn e in do @@ -1109,7 +1112,7 @@ unit_prim_ann = <$> ( gvar (primitiveGVar "toUpper") `ann` (tcon tChar `tfun` tcon tChar) ) - `app` (char 'a' `ann` tcon tChar) + `app` (char 'a' `ann` tcon tChar) <*> char 'A' <*> pure (DefPrim <$> globals) s = evalFullTest maxID builtinTypes gs 2 Syn e @@ -1125,22 +1128,22 @@ unit_prim_partial_map = (mapName, mapDef) <- Examples.map' modName (,,) <$> gvar mapName - `aPP` tcon tChar - `aPP` tcon tChar - `app` gvar (primitiveGVar "toUpper") - `app` list_ - tChar - [ char 'a' - , char 'b' - , char 'c' - ] + `aPP` tcon tChar + `aPP` tcon tChar + `app` gvar (primitiveGVar "toUpper") + `app` list_ + tChar + [ char 'a' + , char 'b' + , char 'c' + ] <*> list_ tChar [ char 'A' , char 'B' , char 'C' ] - `ann` (tcon tList `tapp` tcon tChar) + `ann` (tcon tList `tapp` tcon tChar) <*> pure (M.singleton mapName mapDef <> (DefPrim <$> globals)) s = evalFullTest maxID builtinTypes gs 65 Syn e in do @@ -1226,7 +1229,7 @@ unaryPrimTest f x y = create . withPrimDefs $ \globals -> (,,) <$> gvar (primitiveGVar f) - `app` x + `app` x <*> y <*> pure (DefPrim <$> globals) s = evalFullTest maxID mempty gs 2 Syn e @@ -1239,8 +1242,8 @@ binaryPrimTest f x y z = create . withPrimDefs $ \globals -> (,,) <$> gvar (primitiveGVar f) - `app` x - `app` y + `app` x + `app` y <*> z <*> pure (DefPrim <$> globals) s = evalFullTest maxID mempty gs 2 Syn e diff --git a/primer/test/Tests/FreeVars.hs b/primer/test/Tests/FreeVars.hs index 4680f6f35..1e6601dec 100644 --- a/primer/test/Tests/FreeVars.hs +++ b/primer/test/Tests/FreeVars.hs @@ -2,7 +2,7 @@ module Tests.FreeVars where import Foreword -import qualified Data.Set as Set +import Data.Set qualified as Set import Primer.Builtins import Primer.Core (Kind (KType)) import Primer.Core.DSL diff --git a/primer/test/Tests/Gen/Core/Typed.hs b/primer/test/Tests/Gen/Core/Typed.hs index 27885cda2..7e2dc5bf9 100644 --- a/primer/test/Tests/Gen/Core/Typed.hs +++ b/primer/test/Tests/Gen/Core/Typed.hs @@ -3,9 +3,8 @@ -- generate well-typed terms module Tests.Gen.Core.Typed where +import Data.Map qualified as M import Foreword hiding (diff) - -import qualified Data.Map as M import Gen.Core.Typed ( WT, genChk, @@ -143,18 +142,27 @@ tasty_genCxtExtending_is_extension = extendsGlobal (Cxt{typeDefs = tds1, localCxt = lc1, globalCxt = gc1, smartHoles = sh1}) (Cxt{typeDefs = tds2, localCxt = lc2, globalCxt = gc2, smartHoles = sh2}) = - tds1 `M.isSubmapOf` tds2 - && lc1 == lc2 -- we don't extend the locals - && lc1 == mempty -- and it doesn't make too much sense to do a global extension if already have locals in scope - && gc1 `M.isSubmapOf` gc2 - && sh1 == sh2 + tds1 + `M.isSubmapOf` tds2 + && lc1 + == lc2 -- we don't extend the locals + && lc1 + == mempty -- and it doesn't make too much sense to do a global extension if already have locals in scope + && gc1 + `M.isSubmapOf` gc2 + && sh1 + == sh2 extendsLocal (Cxt{typeDefs = tds1, localCxt = lc1, globalCxt = gc1, smartHoles = sh1}) (Cxt{typeDefs = tds2, localCxt = lc2, globalCxt = gc2, smartHoles = sh2}) = - tds1 == tds2 - && lc1 `M.isSubmapOf` lc2 -- we only extend the locals - && gc1 == gc2 - && sh1 == sh2 + tds1 + == tds2 + && lc1 + `M.isSubmapOf` lc2 -- we only extend the locals + && gc1 + == gc2 + && sh1 + == sh2 tasty_genSyns :: Property tasty_genSyns = withTests 1000 $ diff --git a/primer/test/Tests/Primitives.hs b/primer/test/Tests/Primitives.hs index 7b683ebe9..33c003cae 100644 --- a/primer/test/Tests/Primitives.hs +++ b/primer/test/Tests/Primitives.hs @@ -4,7 +4,7 @@ module Tests.Primitives where import Foreword -import qualified Data.Map as M +import Data.Map qualified as M import Gen.Core.Typed (forAllT, genPrimCon, propertyWT) import Hedgehog (assert) import Hedgehog.Gen (choice) @@ -61,7 +61,8 @@ unit_prim_con_scope_ast = do -- Char is in scope (though the wrong kind to accept 'PrimChar's!) assertBool "Char is not in scope?" $ isRight $ - test $ checkKind (KType `KFun` KType) =<< tcon tChar + test $ + checkKind (KType `KFun` KType) =<< tcon tChar test (synth =<< char 'a') @?= Left (PrimitiveTypeNotInScope tChar) where charASTDef = diff --git a/primer/test/Tests/Question.hs b/primer/test/Tests/Question.hs index 65f3ad79b..1e4297497 100644 --- a/primer/test/Tests/Question.hs +++ b/primer/test/Tests/Question.hs @@ -7,8 +7,8 @@ import Data.List (nub, nubBy) import Gen.Core.Raw (evalExprGen, genKind, genName, genTyVarName, genType) import Hedgehog hiding (Property, check, property) import Hedgehog.Classes -import qualified Hedgehog.Gen as Gen -import qualified Hedgehog.Range as Range +import Hedgehog.Gen qualified as Gen +import Hedgehog.Range qualified as Range import Primer.Builtins import Primer.Core ( Expr, diff --git a/primer/test/Tests/Refine.hs b/primer/test/Tests/Refine.hs index c4de3994c..db8993dce 100644 --- a/primer/test/Tests/Refine.hs +++ b/primer/test/Tests/Refine.hs @@ -3,8 +3,8 @@ module Tests.Refine where import Foreword hiding (diff) import Control.Monad.Fresh (MonadFresh) -import qualified Data.Map as M -import qualified Data.Set as S +import Data.Map qualified as M +import Data.Set qualified as S import Gen.Core.Typed ( forAllT, freshTyVarNameForCxt, @@ -20,8 +20,8 @@ import Hedgehog ( success, (===), ) -import qualified Hedgehog.Gen as Gen -import qualified Hedgehog.Range as Range +import Hedgehog.Gen qualified as Gen +import Hedgehog.Range qualified as Range import Primer.Builtins (builtinModule, tBool, tList, tNat) import Primer.Core ( Expr' (APP, Ann, App, EmptyHole), diff --git a/primer/test/Tests/Serialization.hs b/primer/test/Tests/Serialization.hs index 818573bb7..a8bfc18a7 100644 --- a/primer/test/Tests/Serialization.hs +++ b/primer/test/Tests/Serialization.hs @@ -9,7 +9,7 @@ import Data.Aeson.Encode.Pretty ( encodePretty', ) import Data.ByteString.Lazy as BL -import qualified Data.Map.Strict as Map +import Data.Map.Strict qualified as Map import Data.String (String) import Primer.Action (Action (Move, SetCursor), ActionError (IDNotFound), Movement (Child1)) import Primer.App ( diff --git a/primer/test/Tests/Typecheck.hs b/primer/test/Tests/Typecheck.hs index 8c709d6cb..145d3080e 100644 --- a/primer/test/Tests/Typecheck.hs +++ b/primer/test/Tests/Typecheck.hs @@ -4,7 +4,7 @@ module Tests.Typecheck where import Foreword import Control.Monad.Fresh (MonadFresh) -import qualified Data.Map as Map +import Data.Map qualified as Map import Gen.Core.Raw ( evalExprGen, genTyConName, @@ -16,8 +16,8 @@ import Gen.Core.Typed ( propertyWT, ) import Hedgehog hiding (Property, check, property, withDiscards, withTests) -import qualified Hedgehog.Gen as Gen -import qualified Hedgehog.Range as Range +import Hedgehog.Gen qualified as Gen +import Hedgehog.Range qualified as Range import Optics (over) import Primer.App ( Prog, diff --git a/primer/test/Tests/Unification.hs b/primer/test/Tests/Unification.hs index 1387ce766..14721d47d 100644 --- a/primer/test/Tests/Unification.hs +++ b/primer/test/Tests/Unification.hs @@ -3,8 +3,8 @@ module Tests.Unification where import Foreword hiding (diff) import Control.Monad.Fresh (MonadFresh) -import qualified Data.Map as M -import qualified Data.Set as S +import Data.Map qualified as M +import Data.Set qualified as S import Gen.Core.Typed ( WT, forAllT, @@ -25,8 +25,8 @@ import Hedgehog ( failure, (===), ) -import qualified Hedgehog.Gen as Gen -import qualified Hedgehog.Range as Range +import Hedgehog.Gen qualified as Gen +import Hedgehog.Range qualified as Range import Primer.Builtins (builtinModule, tList, tNat) import Primer.Core ( ASTTypeDef (ASTTypeDef, astTypeDefConstructors, astTypeDefNameHints, astTypeDefParameters), diff --git a/primer/test/Tests/Zipper.hs b/primer/test/Tests/Zipper.hs index cf6e58fbc..a32254386 100644 --- a/primer/test/Tests/Zipper.hs +++ b/primer/test/Tests/Zipper.hs @@ -10,7 +10,7 @@ import Gen.Core.Raw ( runExprGen, ) import Hedgehog hiding (Property, property) -import qualified Hedgehog.Gen as Gen +import Hedgehog.Gen qualified as Gen import Primer.Core import Primer.Zipper import TestUtils (Property, property) diff --git a/primer/test/Tests/Zipper/BindersAbove.hs b/primer/test/Tests/Zipper/BindersAbove.hs index 4cf548254..54be2519e 100644 --- a/primer/test/Tests/Zipper/BindersAbove.hs +++ b/primer/test/Tests/Zipper/BindersAbove.hs @@ -3,7 +3,7 @@ module Tests.Zipper.BindersAbove where import Foreword -import qualified Data.Set as S +import Data.Set qualified as S import Primer.Action ( Movement (..), moveExpr,