Skip to content

Commit 1e7943e

Browse files
Restyled by fourmolu (#2560)
Co-authored-by: Restyled.io <[email protected]>
1 parent 8bc4c40 commit 1e7943e

File tree

12 files changed

+71
-68
lines changed

12 files changed

+71
-68
lines changed

src/swarm-lang/Swarm/Language/LSP.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import Language.LSP.Protocol.Types qualified as LSP
2222
import Language.LSP.Server
2323
import Language.LSP.VFS (VirtualFile (..), virtualFileText)
2424
import Swarm.Failure (SystemFailure (..))
25-
import Swarm.Language.Load (SyntaxWithImports (..))
2625
import Swarm.Language.LSP.Hover qualified as H
2726
import Swarm.Language.LSP.VarUsage qualified as VU
27+
import Swarm.Language.Load (SyntaxWithImports (..))
2828
import Swarm.Language.Parser.Util (getLocRange)
2929
import Swarm.Language.Pipeline (processSource)
3030
import Swarm.Language.Syntax (SrcLoc (..), eraseRaw)

src/swarm-lang/Swarm/Language/Load.hs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import Swarm.Language.Parser.Core (defaultParserConfig, importLoc)
3535
import Swarm.Language.Syntax
3636
import Swarm.Language.Syntax.Import hiding (ImportPhase (..))
3737
import Swarm.Language.Syntax.Import qualified as Import
38-
import Swarm.Language.Syntax.Util (Erasable(..))
38+
import Swarm.Language.Syntax.Util (Erasable (..))
3939
import Swarm.Language.Types (TCtx, TDCtx, UCtx)
4040
import Swarm.Pretty (prettyText)
4141
import Swarm.Util (readFileMayT, showT)
@@ -174,7 +174,7 @@ resolveImport parent loc = do
174174

175175
srcMap <- get @(SourceMap Resolved)
176176
resMod <- case M.lookup canonicalLoc srcMap of
177-
Just m -> pure m -- Already loaded - do nothing
177+
Just m -> pure m -- Already loaded - do nothing
178178
Nothing -> do
179179
-- Record this import loc in the source map using a temporary, empty module,
180180
-- to prevent it from attempting to load itself recursively
@@ -206,17 +206,17 @@ resolveImport parent loc = do
206206
-- evaluating them once.
207207
validateImport :: forall sig m. (Has (Throw SystemFailure) sig m) => ResLoc -> Module Resolved -> m ()
208208
validateImport loc = maybe (pure ()) validate . moduleTerm
209-
where
210-
validate :: Syntax Resolved -> m ()
211-
validate = validateTerm . _sTerm
212-
213-
validateTerm :: Term Resolved -> m ()
214-
validateTerm = \case
215-
SLet LSDef _ _ _ _ _ _ t -> validate t
216-
SImportIn _ t -> validate t
217-
STydef _ _ _ t -> validate t
218-
TConst Noop -> pure ()
219-
t -> throwError $ ImpureImport loc (prettyText t)
209+
where
210+
validate :: Syntax Resolved -> m ()
211+
validate = validateTerm . _sTerm
212+
213+
validateTerm :: Term Resolved -> m ()
214+
validateTerm = \case
215+
SLet LSDef _ _ _ _ _ _ t -> validate t
216+
SImportIn _ t -> validate t
217+
STydef _ _ _ t -> validate t
218+
TConst Noop -> pure ()
219+
t -> throwError $ ImpureImport loc (prettyText t)
220220

221221
-- | Try to read and parse a term from a specific import location,
222222
-- either over the network or on disk.
@@ -233,7 +233,6 @@ readLoc loc = do
233233

234234
-- Try to read the file from network/disk, depending on the anchor
235235
src <- case importAnchor loc of
236-
237236
-- Read from network
238237
Web_ {} -> do
239238
-- Try to parse the URL

src/swarm-lang/Swarm/Language/Parser/Value.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ readValue ty txt = do
5252
-- encountered; we can't read those anyway.
5353
sResolved <- eitherToMaybe . run . runError @SystemFailure $ resolve' s
5454
-- Now, make sure the resolved term typechecks at the given type.
55-
_ <- eitherToMaybe . runError @ContextualTypeErr $
56-
checkTop Ctx.empty Ctx.empty emptyTDCtx M.empty sResolved ty
55+
_ <-
56+
eitherToMaybe . runError @ContextualTypeErr $
57+
checkTop Ctx.empty Ctx.empty emptyTDCtx M.empty sResolved ty
5758
-- Finally, turn the term into a value.
5859
toValue $ s ^. sTerm
5960

src/swarm-lang/Swarm/Language/TDVar.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ mkTDVar v loc x = TDVar x v loc
7474
-- | Set the version number of a TDVar, leaving the name and import
7575
-- location unchanged.
7676
setVersion :: Int -> TDVar -> TDVar
77-
setVersion ver v = v { tdVarVersion = ver }
77+
setVersion ver v = v {tdVarVersion = ver}
7878

7979
-- | Pretty-print a type definition variable, given an extra argument
8080
-- representing the latest version of any variable with this name.

src/swarm-lang/Swarm/Language/Typecheck.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,19 +889,19 @@ inferTop ::
889889
Has (Error ContextualTypeErr) sig m =>
890890
TCtx -> ReqCtx -> TDCtx -> SourceMap Resolved -> Syntax Resolved -> m (SyntaxWithImports Typed)
891891
inferTop ctx reqCtx tdCtx srcMap =
892-
fmap (uncurry SyntaxWithImports) .
893-
runTC ctx reqCtx tdCtx Ctx.empty srcMap .
894-
infer
892+
fmap (uncurry SyntaxWithImports)
893+
. runTC ctx reqCtx tdCtx Ctx.empty srcMap
894+
. infer
895895

896896
-- | Top level type checking function.
897897
checkTop ::
898898
Has (Error ContextualTypeErr) sig m =>
899899
TCtx -> ReqCtx -> TDCtx -> SourceMap Resolved -> Syntax Resolved -> Type -> m (SyntaxWithImports Typed)
900900
checkTop ctx reqCtx tdCtx srcMap t =
901-
fmap (uncurry SyntaxWithImports) .
902-
runTC ctx reqCtx tdCtx Ctx.empty srcMap .
903-
check t .
904-
toU
901+
fmap (uncurry SyntaxWithImports)
902+
. runTC ctx reqCtx tdCtx Ctx.empty srcMap
903+
. check t
904+
. toU
905905

906906
-- | Infer the type of a term, returning a type-annotated term.
907907
--

src/swarm-lang/Swarm/Language/Types.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,12 @@ makeLenses ''TydefInfo
841841
-- more than one version), so we can tell when a type definition has
842842
-- been shadowed.
843843
data TDCtx = TDCtx
844-
{ -- | Mapping from fully resolved + versioned TDVars to
845-
-- corresponding type definition info record
846-
getTDCtx :: Ctx TDVar TydefInfo
847-
-- | Mapping from raw names to the latest in-scope import location
848-
-- + version number for that name.
844+
{ getTDCtx :: Ctx TDVar TydefInfo
845+
-- ^ Mapping from fully resolved + versioned TDVars to
846+
-- corresponding type definition info record
849847
, getTDResolved :: Map Text (Int, Maybe (ImportLoc Resolved))
848+
-- ^ Mapping from raw names to the latest in-scope import location
849+
-- + version number for that name.
850850
}
851851
deriving (Eq, Show, Generic, Data, Hashable, ToJSON)
852852

@@ -869,7 +869,7 @@ addBindingTD :: TDVar -> TydefInfo -> TDCtx -> TDCtx
869869
addBindingTD v info (TDCtx tdCtx tdVersions) =
870870
let x = tdVarName v
871871
ver' = maybe 0 (succ . fst) $ M.lookup x tdVersions
872-
in TDCtx (Ctx.addBinding (setVersion ver' v) info tdCtx) (M.insert x (ver', tdModule v) tdVersions)
872+
in TDCtx (Ctx.addBinding (setVersion ver' v) info tdCtx) (M.insert x (ver', tdModule v) tdVersions)
873873

874874
-- | Locally extend the ambient type definition context with an
875875
-- additional binding, via 'addBindingTD'.

src/swarm-lang/Swarm/Language/Value.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ makeLenses ''Env
179179

180180
-- | Create an environment which is empty except for an initial SourceMap.
181181
envFromSrcMap :: SourceMap Elaborated -> Env
182-
envFromSrcMap srcMap = emptyEnv { _envSourceMap = srcMap }
182+
envFromSrcMap srcMap = emptyEnv {_envSourceMap = srcMap}
183183

184184
emptyEnv :: Env
185185
emptyEnv = Env Ctx.empty Ctx.empty Ctx.empty emptyTDCtx M.empty

src/swarm-tui/Swarm/TUI/Controller.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ validateREPLForm s =
890890
(theType, errSrcLoc) = case readTerm' defaultParserConfig uinput of
891891
Left err ->
892892
let (((_y1, x1), (_y2, x2)), _msg) = showErrorPos err
893-
in (Nothing, Left (SrcLoc Nothing x1 x2))
893+
in (Nothing, Left (SrcLoc Nothing x1 x2))
894894
Right Nothing -> (Nothing, Right ())
895895
Right (Just theTerm) ->
896896
-- Explicitly ignore REPL entries with imports,
@@ -899,15 +899,15 @@ validateREPLForm s =
899899
-- be properly resolved and checked when the
900900
-- user hits enter.
901901
let res = run . runError @SystemFailure $ processTermNoImports uinput theTerm (Just env)
902-
in case res of
903-
Right t -> (Just (t ^. sType), Right ())
904-
Left (DoesNotTypecheck loc _) -> (Nothing, Left loc)
905-
-- Don't signal an error if the REPL entry contained an import
906-
Left (DisallowedImport _) -> (Nothing, Right ())
907-
_ -> (Nothing, Right ())
902+
in case res of
903+
Right t -> (Just (t ^. sType), Right ())
904+
Left (DoesNotTypecheck loc _) -> (Nothing, Left loc)
905+
-- Don't signal an error if the REPL entry contained an import
906+
Left (DisallowedImport _) -> (Nothing, Right ())
907+
_ -> (Nothing, Right ())
908908
in s
909-
& uiGameplay . uiREPL . replValid .~ errSrcLoc
910-
& uiGameplay . uiREPL . replType .~ theType
909+
& uiGameplay . uiREPL . replValid .~ errSrcLoc
910+
& uiGameplay . uiREPL . replType .~ theType
911911
SearchPrompt _ -> s
912912
where
913913
uinput = s ^. uiGameplay . uiREPL . replPromptText

src/swarm-tui/Swarm/TUI/Model.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ import Swarm.Game.State.Runtime
125125
import Swarm.Game.State.Substate
126126
import Swarm.Game.Tick (TickNumber (..))
127127
import Swarm.Game.World (Seed)
128-
import Swarm.Language.Text.Markdown qualified as Markdown
129128
import Swarm.Language.Syntax (Phase (..))
129+
import Swarm.Language.Text.Markdown qualified as Markdown
130130
import Swarm.Log
131131
import Swarm.TUI.Inventory.Sorting
132132
import Swarm.TUI.Model.DebugOption (DebugOption)

src/swarm-util/Swarm/Failure.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ instance PrettyPrec SystemFailure where
165165
DisallowedImport _imp -> "Import is not allowed here"
166166
ImpureImport imp t ->
167167
nest 2 . vcat $
168-
[ "While processing import" <+> ppr imp <> ":"
169-
, "Imported modules must only contain imports + definitions, but found:"
170-
, squotes (pretty t)
171-
]
168+
[ "While processing import" <+> ppr imp <> ":"
169+
, "Imported modules must only contain imports + definitions, but found:"
170+
, squotes (pretty t)
171+
]
172172
CustomFailure m -> pretty m

0 commit comments

Comments
 (0)