From 6d14ff1b7d4d7b77a7de65448bc5699476ec8f71 Mon Sep 17 00:00:00 2001 From: Greg Pfeil Date: Wed, 27 Nov 2024 11:36:41 -0700 Subject: [PATCH] Run Ormolu 0.7.2.0 on the entire code base --- parser-typechecker/src/Unison/Codebase.hs | 1 - .../src/Unison/Codebase/SqliteCodebase.hs | 2 +- parser-typechecker/src/Unison/Typechecker.hs | 4 ++-- .../Editor/HandleInput/EditNamespace.hs | 4 ++-- .../Editor/HandleInput/FindAndReplace.hs | 5 +++-- .../Editor/HandleInput/RuntimeUtils.hs | 14 ++++++++------ .../src/Unison/Codebase/Transcript/Runner.hs | 3 ++- .../src/Unison/CommandLine/FZFResolvers.hs | 4 ++-- unison-core/src/Unison/ABT/Normalized.hs | 19 ++++++++++--------- .../src/Unison/Names/ResolutionResult.hs | 2 +- unison-runtime/src/Unison/Runtime/Builtin.hs | 6 +++--- .../src/Unison/Runtime/Foreign/Function.hs | 2 +- .../src/Unison/Runtime/MCode/Serialize.hs | 2 +- .../Test/Runtime/MCode/Serialization.hs | 2 +- 14 files changed, 37 insertions(+), 33 deletions(-) diff --git a/parser-typechecker/src/Unison/Codebase.hs b/parser-typechecker/src/Unison/Codebase.hs index fae356d3a2..c790b759fb 100644 --- a/parser-typechecker/src/Unison/Codebase.hs +++ b/parser-typechecker/src/Unison/Codebase.hs @@ -402,7 +402,6 @@ typeLookupForDependencies codebase s = do in depthFirstAccumTypes z (DD.typeDependencies dd) Nothing -> pure tl goType tl Reference.Builtin {} = pure tl -- codebase isn't consulted for builtins - unseen :: TL.TypeLookup Symbol a -> Reference -> Bool unseen tl r = isNothing diff --git a/parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs b/parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs index 498736d031..e4d363b4c0 100644 --- a/parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs +++ b/parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs @@ -46,9 +46,9 @@ import Unison.Type (Type) import Unison.Util.Cache qualified as Cache import Unison.WatchKind qualified as UF import UnliftIO (finally) -import UnliftIO.Directory (createDirectoryIfMissing, doesFileExist) import UnliftIO qualified as UnliftIO import UnliftIO.Concurrent qualified as UnliftIO +import UnliftIO.Directory (createDirectoryIfMissing, doesFileExist) import UnliftIO.STM debug :: Bool diff --git a/parser-typechecker/src/Unison/Typechecker.hs b/parser-typechecker/src/Unison/Typechecker.hs index 340572df72..20b4fe8918 100644 --- a/parser-typechecker/src/Unison/Typechecker.hs +++ b/parser-typechecker/src/Unison/Typechecker.hs @@ -21,7 +21,7 @@ where import Control.Lens import Control.Monad.Fail (fail) -import Control.Monad.State (StateT, get, modify, execState, State) +import Control.Monad.State (State, StateT, execState, get, modify) import Control.Monad.Writer import Data.Foldable import Data.Map qualified as Map @@ -233,7 +233,7 @@ typeDirectedNameResolution ppe oldNotes oldType env = do addTypedComponent (Context.TopLevelComponent vtts) = for_ vtts \(v, typ, _) -> let name = Name.unsafeParseVar (Var.reset v) - in #topLevelComponents %= Map.insert name (NamedReference name typ (Context.ReplacementVar v)) + in #topLevelComponents %= Map.insert name (NamedReference name typ (Context.ReplacementVar v)) addTypedComponent _ = pure () suggest :: [Resolution v loc] -> Result (Notes v loc) () diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput/EditNamespace.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput/EditNamespace.hs index d50e776f05..391801ef17 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput/EditNamespace.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput/EditNamespace.hs @@ -21,13 +21,13 @@ import Unison.HashQualified qualified as HQ import Unison.Name (Name) import Unison.Names qualified as Names import Unison.Prelude +import Unison.PrettyPrintEnv.Names qualified as PPE import Unison.PrettyPrintEnvDecl (PrettyPrintEnvDecl (..)) +import Unison.PrettyPrintEnvDecl.Names qualified as PPED import Unison.Referent qualified as Referent import Unison.Server.Backend qualified as Backend import Unison.Syntax.DeclPrinter qualified as DeclPrinter import Unison.Util.Monoid (foldMapM) -import qualified Unison.PrettyPrintEnv.Names as PPE -import qualified Unison.PrettyPrintEnvDecl.Names as PPED handleEditNamespace :: OutputLocation -> [Path] -> Cli () handleEditNamespace outputLoc paths0 = do diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput/FindAndReplace.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput/FindAndReplace.hs index 35d9d786da..b18b360db2 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput/FindAndReplace.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput/FindAndReplace.hs @@ -1,7 +1,7 @@ module Unison.Codebase.Editor.HandleInput.FindAndReplace ( handleStructuredFindReplaceI, handleStructuredFindI, - handleTextFindI + handleTextFindI, ) where @@ -129,7 +129,8 @@ handleTextFindI allowLib tokens = do txts (Term.Float' haystack) = ABT.Found [Text.pack (show haystack)] txts (Term.Char' haystack) = ABT.Found [Text.pack [haystack]] txts (Term.Match' _ cases) = ABT.Found r - where r = join $ Pattern.foldMap' txtPattern . Term.matchPattern <$> cases + where + r = join $ Pattern.foldMap' txtPattern . Term.matchPattern <$> cases txts _ = ABT.Continue txtPattern (Pattern.Text _ txt) = [txt] txtPattern _ = [] diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput/RuntimeUtils.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput/RuntimeUtils.hs index 5c13ffb8a9..8b903dc65f 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput/RuntimeUtils.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput/RuntimeUtils.hs @@ -4,9 +4,10 @@ module Unison.Codebase.Editor.HandleInput.RuntimeUtils evalPureUnison, displayDecompileErrors, selectRuntime, - EvalMode (..) + EvalMode (..), ) where + import Control.Lens import Control.Monad.Reader (ask) import Unison.ABT qualified as ABT @@ -32,11 +33,12 @@ import Unison.WatchKind qualified as WK data EvalMode = Sandboxed | Permissive | Native selectRuntime :: EvalMode -> Cli (Runtime.Runtime Symbol) -selectRuntime mode = ask <&> \case - Cli.Env { runtime, sandboxedRuntime, nativeRuntime } - | Permissive <- mode -> runtime - | Sandboxed <- mode -> sandboxedRuntime - | Native <- mode -> nativeRuntime +selectRuntime mode = + ask <&> \case + Cli.Env {runtime, sandboxedRuntime, nativeRuntime} + | Permissive <- mode -> runtime + | Sandboxed <- mode -> sandboxedRuntime + | Native <- mode -> nativeRuntime displayDecompileErrors :: [Runtime.Error] -> Cli () displayDecompileErrors errs = Cli.respond (PrintMessage msg) diff --git a/unison-cli/src/Unison/Codebase/Transcript/Runner.hs b/unison-cli/src/Unison/Codebase/Transcript/Runner.hs index 54173d45be..caac754a3c 100644 --- a/unison-cli/src/Unison/Codebase/Transcript/Runner.hs +++ b/unison-cli/src/Unison/Codebase/Transcript/Runner.hs @@ -202,7 +202,8 @@ run isTest verbosity dir codebase runtime sbRuntime nRuntime ucmVersion baseURL hide <- hideOutput False unless hide $ -- We shorten the terminal width, because "Transcript" manages a 2-space indent for output lines. - outputUcmLine . UcmOutputLine . Text.pack $ Pretty.toPlain (terminalWidth - 2) line + outputUcmLine . UcmOutputLine . Text.pack $ + Pretty.toPlain (terminalWidth - 2) line maybeDieWithMsg :: String -> IO () maybeDieWithMsg msg = do diff --git a/unison-cli/src/Unison/CommandLine/FZFResolvers.hs b/unison-cli/src/Unison/CommandLine/FZFResolvers.hs index 8115db9554..d72e6db9bd 100644 --- a/unison-cli/src/Unison/CommandLine/FZFResolvers.hs +++ b/unison-cli/src/Unison/CommandLine/FZFResolvers.hs @@ -175,9 +175,9 @@ projectBranchOptions codebase projCtx _searchBranch0 = do & foldMap ( \(names, projIds) -> if projIds.project == projCtx.project.projectId - -- If the branch is in the current project, put a shortened version of the branch name first, + then -- If the branch is in the current project, put a shortened version of the branch name first, -- then the long-form name at the end of the list (in case the user still types the full name) - then [(0 :: Int, "/" <> into @Text names.branch), (2, into @Text names)] + [(0 :: Int, "/" <> into @Text names.branch), (2, into @Text names)] else [(1, into @Text names)] ) -- Put branches in this project first. diff --git a/unison-core/src/Unison/ABT/Normalized.hs b/unison-core/src/Unison/ABT/Normalized.hs index 242ae46d08..3281366f08 100644 --- a/unison-core/src/Unison/ABT/Normalized.hs +++ b/unison-core/src/Unison/ABT/Normalized.hs @@ -25,7 +25,7 @@ where import Data.Bifoldable import Data.Bifunctor import Data.Foldable (toList) -import Data.Functor.Identity (Identity(..)) +import Data.Functor.Identity (Identity (..)) import Data.Map.Strict (Map) import Data.Map.Strict qualified as Map import Data.Maybe (fromMaybe) @@ -208,10 +208,10 @@ transform phi (TTm body) = TTm . second (transform phi) $ phi body transform phi (TAbs u body) = TAbs u $ transform phi body visit :: - Applicative g => - Bifoldable f => - Traversable (f v) => - Var v => + (Applicative g) => + (Bifoldable f) => + (Traversable (f v)) => + (Var v) => (Term f v -> Maybe (g (Term f v))) -> Term f v -> g (Term f v) @@ -220,9 +220,10 @@ visit h t = flip fromMaybe (h t) $ case out t of Tm body -> TTm <$> traverse (visit h) body visitPure :: - Bifoldable f => - Traversable (f v) => - Var v => + (Bifoldable f) => + (Traversable (f v)) => + (Var v) => (Term f v -> Maybe (Term f v)) -> - Term f v -> Term f v + Term f v -> + Term f v visitPure h = runIdentity . visit (fmap pure . h) diff --git a/unison-core/src/Unison/Names/ResolutionResult.hs b/unison-core/src/Unison/Names/ResolutionResult.hs index 3b7246a35e..081e3b5eae 100644 --- a/unison-core/src/Unison/Names/ResolutionResult.hs +++ b/unison-core/src/Unison/Names/ResolutionResult.hs @@ -6,12 +6,12 @@ module Unison.Names.ResolutionResult ) where +import Unison.HashQualified (HashQualified) import Unison.Name (Name) import Unison.Names (Names) import Unison.Prelude import Unison.Reference (TypeReference) import Unison.Referent (Referent) -import Unison.HashQualified (HashQualified) data ResolutionError ref = NotFound diff --git a/unison-runtime/src/Unison/Runtime/Builtin.hs b/unison-runtime/src/Unison/Runtime/Builtin.hs index a26d37109b..f073f54227 100644 --- a/unison-runtime/src/Unison/Runtime/Builtin.hs +++ b/unison-runtime/src/Unison/Runtime/Builtin.hs @@ -522,7 +522,7 @@ dropn :: (Var v) => SuperNormal v dropn = binop0 4 $ \[x, y, b, r, tag, n] -> TLetD b UN (TPrm LEQN [x, y]) -- TODO: Can we avoid this work until after the branch? - -- Should probably just replace this with an instruction. + -- Should probably just replace this with an instruction. . TLetD tag UN (TLit $ I $ fromIntegral $ unboxedTypeTagToInt NatTag) . TLetD r UN (TPrm SUBN [x, y]) . TLetD n UN (TPrm CAST [r, tag]) @@ -815,8 +815,8 @@ andb = binop0 0 $ \[p, q] -> coerceType :: UnboxedTypeTag -> SuperNormal Symbol coerceType destType = unop0 1 $ \[v, tag] -> - TLetD tag UN (TLit $ I $ fromIntegral $ unboxedTypeTagToInt destType) $ - TPrm CAST [v, tag] + TLetD tag UN (TLit $ I $ fromIntegral $ unboxedTypeTagToInt destType) $ + TPrm CAST [v, tag] -- This version of unsafeCoerce is the identity function. It works -- only if the two types being coerced between are actually the same, diff --git a/unison-runtime/src/Unison/Runtime/Foreign/Function.hs b/unison-runtime/src/Unison/Runtime/Foreign/Function.hs index b9bb278112..13b85e2b14 100644 --- a/unison-runtime/src/Unison/Runtime/Foreign/Function.hs +++ b/unison-runtime/src/Unison/Runtime/Foreign/Function.hs @@ -28,8 +28,8 @@ import Network.UDP (UDPSocket) import System.IO (BufferMode (..), Handle, IOMode, SeekMode) import Unison.Builtin.Decls qualified as Ty import Unison.Reference (Reference) -import Unison.Runtime.Array qualified as PA import Unison.Runtime.ANF (Code, PackedTag (..), Value, internalBug) +import Unison.Runtime.Array qualified as PA import Unison.Runtime.Exception import Unison.Runtime.Foreign import Unison.Runtime.MCode diff --git a/unison-runtime/src/Unison/Runtime/MCode/Serialize.hs b/unison-runtime/src/Unison/Runtime/MCode/Serialize.hs index 92f0c6074a..0dcc2cd2cf 100644 --- a/unison-runtime/src/Unison/Runtime/MCode/Serialize.hs +++ b/unison-runtime/src/Unison/Runtime/MCode/Serialize.hs @@ -17,8 +17,8 @@ import Data.Bytes.VarInt import Data.Void (Void) import Data.Word (Word64) import GHC.Exts (IsList (..)) -import Unison.Runtime.Array (PrimArray) import Unison.Runtime.ANF (PackedTag (..)) +import Unison.Runtime.Array (PrimArray) import Unison.Runtime.MCode hiding (MatchT) import Unison.Runtime.Serialize import Unison.Util.Text qualified as Util.Text diff --git a/unison-runtime/tests/Unison/Test/Runtime/MCode/Serialization.hs b/unison-runtime/tests/Unison/Test/Runtime/MCode/Serialization.hs index 18e4529001..1b95a96b40 100644 --- a/unison-runtime/tests/Unison/Test/Runtime/MCode/Serialization.hs +++ b/unison-runtime/tests/Unison/Test/Runtime/MCode/Serialization.hs @@ -16,7 +16,7 @@ import Unison.Prelude import Unison.Runtime.Interface import Unison.Runtime.MCode (Args (..), BPrim1, BPrim2, Branch, Comb, CombIx (..), GBranch (..), GComb (..), GCombInfo (..), GInstr (..), GRef (..), GSection (..), Instr, MLit (..), Ref, Section, UPrim1, UPrim2) import Unison.Runtime.Machine (Combs) -import Unison.Runtime.TypeTags (PackedTag(..)) +import Unison.Runtime.TypeTags (PackedTag (..)) import Unison.Test.Gen import Unison.Util.EnumContainers (EnumMap, EnumSet) import Unison.Util.EnumContainers qualified as EC