@@ -77,8 +77,10 @@ failOn errs = case (reverse errs) of
7777 fail (Text. unpack lastMsg)
7878
7979cdCmd :: FilePath -> REPL ()
80- cdCmd f | null f = liftIO $ putStrLn $ " Error: The :cd command requires a path argument"
81- | otherwise = do
80+ cdCmd f
81+ | null f =
82+ liftIO $ putStrLn " Error: The :cd command requires a path argument"
83+ | otherwise = do
8284 exists <- liftIO $ doesDirectoryExist f
8385 if exists
8486 then liftIO $ setCurrentDirectory f
@@ -141,7 +143,9 @@ quitCmd =
141143
142144searchCmd :: Text -> REPL ()
143145searchCmd str
144- | Text. null str = liftIO $ putStrLn $ " Error: The :search command requires at least one argument"
146+ | Text. null str =
147+ let msg = " Error: The :search command requires at least one argument" in
148+ liftIO $ putStrLn msg
145149 | otherwise = do
146150
147151 -- FUTURE: it would be nice to be able to use the words
@@ -162,7 +166,8 @@ searchCmd str
162166 rw <- getTopLevelRW
163167 let environ = rwEnviron rw
164168 rebindables = rwRebindables rw
165- errs_or_pat <- liftIO $ Loader. readSchemaPattern replFileName environ rebindables avail str
169+ errs_or_pat <- liftIO $
170+ Loader. readSchemaPattern replFileName environ rebindables avail str
166171 pat <- case errs_or_pat of
167172 Left errs -> failOn errs
168173 Right p -> return p
@@ -213,7 +218,8 @@ searchCmd str
213218 " with unexpected lifecycle " <> Text. pack (show lc)
214219 ]
215220 (visMatches, expMatches, depMatches) =
216- Map. foldrWithKey inspect (Map. empty, Map. empty, Map. empty) allMatches
221+ let empty = (Map. empty, Map. empty, Map. empty) in
222+ Map. foldrWithKey inspect empty allMatches
217223
218224 printMatch (name, (lc, ty)) = do
219225 let ty' = PPS. pShowText ty
@@ -252,13 +258,13 @@ searchCmd str
252258 else do
253259 liftIO $ putStrLn " No matches."
254260 if not (Map. null expMatches) then do
255- liftIO $ putStrLn $ " The following experimental matches require " ++
256- " enable_experimental:"
261+ liftIO $ putStrLn $ " The following experimental matches " ++
262+ " require enable_experimental:"
257263 printMatches expMatches
258264 alsoDeprecated
259265 else if not (Map. null depMatches) then do
260266 liftIO $ putStrLn $ " The following deprecated matches require " ++
261- " enable_deprecated:"
267+ " enable_deprecated:"
262268 printMatches depMatches
263269 else
264270 pure ()
@@ -280,13 +286,15 @@ tenvCmd = do
280286
281287typeOfCmd :: Text -> REPL ()
282288typeOfCmd str
283- | Text. null str = liftIO $ putStrLn " Error: The :type command requires an argument"
289+ | Text. null str =
290+ liftIO $ putStrLn " Error: The :type command requires an argument"
284291 | otherwise = do
285292 rw <- getTopLevelRW
286293 let environ = rwEnviron rw
287294 rebindables = rwRebindables rw
288295 avail = rwPrimsAvail rw
289- errs_or_expr <- liftIO $ Loader. readExpression replFileName environ rebindables avail str
296+ errs_or_expr <- liftIO $
297+ Loader. readExpression replFileName environ rebindables avail str
290298 (schema, _expr) <- case errs_or_expr of
291299 Left errs -> failOn errs
292300 Right info -> return info
@@ -448,7 +456,8 @@ executeReplCommand cmd args0 =
448456 [] -> action " "
449457 [arg] -> action arg
450458 _ -> do
451- let msg = " The command " <> cName cmd <> " takes only one argument"
459+ let msg = " The command " <> cName cmd <>
460+ " takes only one argument"
452461 liftIO $ TextIO. putStrLn msg
453462 in
454463 exceptionProtect $ case cBody cmd of
@@ -467,7 +476,9 @@ executeReplCommand cmd args0 =
467476-- | Execute REPL :-command text.
468477executeReplCommandText :: Text -> REPL ()
469478executeReplCommandText text =
470- let textWords = filter (\ w -> not $ Text. null w) $ Text. split isSpace text in
479+ let textWords =
480+ filter (\ w -> not $ Text. null w) $ Text. split isSpace text
481+ in
471482 case textWords of
472483 [] -> pure ()
473484 cmdName : args ->
@@ -476,8 +487,9 @@ executeReplCommandText text =
476487 -- Historically SAW accepts ":?cmd" without a space
477488 if Text. isPrefixOf " :?" cmdName then
478489 executeReplCommandText $ " :? " <> Text. drop 2 cmdName
479- else
480- liftIO $ TextIO. putStrLn $ " Unknown command: " <> cmdName
490+ else do
491+ let msg = " Unknown command: " <> cmdName
492+ liftIO $ TextIO. putStrLn msg
481493 [cmd] ->
482494 executeReplCommand cmd args
483495 cmds -> liftIO $ do
0 commit comments