Skip to content

Commit

Permalink
Run Ormolu 0.7.2.0 on the entire code base
Browse files Browse the repository at this point in the history
  • Loading branch information
sellout committed Nov 27, 2024
1 parent 9ca3fc9 commit 6d14ff1
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 33 deletions.
1 change: 0 additions & 1 deletion parser-typechecker/src/Unison/Codebase.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions parser-typechecker/src/Unison/Typechecker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Unison.Codebase.Editor.HandleInput.FindAndReplace
( handleStructuredFindReplaceI,
handleStructuredFindI,
handleTextFindI
handleTextFindI,
)
where

Expand Down Expand Up @@ -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 _ = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion unison-cli/src/Unison/Codebase/Transcript/Runner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions unison-cli/src/Unison/CommandLine/FZFResolvers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 10 additions & 9 deletions unison-core/src/Unison/ABT/Normalized.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
2 changes: 1 addition & 1 deletion unison-core/src/Unison/Names/ResolutionResult.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions unison-runtime/src/Unison/Runtime/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion unison-runtime/src/Unison/Runtime/Foreign/Function.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion unison-runtime/src/Unison/Runtime/MCode/Serialize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6d14ff1

Please sign in to comment.