Skip to content

Commit

Permalink
Merge pull request #5469 from sellout/ormoluize
Browse files Browse the repository at this point in the history
Run Ormolu 0.7.2.0 across the code base
  • Loading branch information
aryairani authored Dec 2, 2024
2 parents d17b1f6 + 606419a commit 99baffd
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 36 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,11 @@ 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 <&> \Cli.Env {runtime, sandboxedRuntime, nativeRuntime} -> case mode of
Permissive -> runtime
Sandboxed -> sandboxedRuntime
Native -> nativeRuntime

displayDecompileErrors :: [Runtime.Error] -> Cli ()
displayDecompileErrors errs = Cli.respond (PrintMessage msg)
Expand Down
5 changes: 3 additions & 2 deletions unison-cli/src/Unison/Codebase/Editor/Input.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ data Input
| PullI !PullSourceTarget !PullMode
| PushRemoteBranchI PushRemoteBranchInput
| ResetI (BranchId2 {- namespace to reset it to -}) (Maybe UnresolvedProjectBranch {- ProjectBranch to reset -})
| -- todo: Q: Does it make sense to publish to not-the-root of a Github repo?
| -- | used in Welcome module to give directions to user
--
-- todo: Q: Does it make sense to publish to not-the-root of a Github repo?
-- Does it make sense to fork from not-the-root of a Github repo?
-- used in Welcome module to give directions to user
CreateMessage (P.Pretty P.ColorText)
| -- Change directory.
SwitchBranchI Path'
Expand Down
4 changes: 2 additions & 2 deletions unison-cli/src/Unison/Codebase/Transcript/Runner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ run isTest verbosity dir codebase runtime sbRuntime nRuntime ucmVersion baseURL
outputUcmResult :: Pretty.Pretty Pretty.ColorText -> IO ()
outputUcmResult line = do
hide <- hideOutput False
unless hide $
unless hide . outputUcmLine . UcmOutputLine . Text.pack $
-- We shorten the terminal width, because "Transcript" manages a 2-space indent for output lines.
outputUcmLine . UcmOutputLine . Text.pack $ Pretty.toPlain (terminalWidth - 2) line
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
14 changes: 5 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,7 @@ 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 +217,8 @@ 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 99baffd

Please sign in to comment.