Skip to content

Commit 0c236a4

Browse files
Merge #839: Basic polymorphism refactor
Clean-up refactor, with some equivalent code simplification, some functor fusioning in executable.
2 parents 573c035 + 9c1dd44 commit 0c236a4

35 files changed

+311
-303
lines changed

main/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ main = do
5555
Nothing -> case expression opts of
5656
Just s -> handleResult opts Nothing (parseNixTextLoc s)
5757
Nothing -> case fromFile opts of
58-
Just "-" -> mapM_ (processFile opts) =<< (lines <$> liftIO getContents)
58+
Just "-" -> mapM_ (processFile opts) . lines =<< liftIO getContents
5959
Just path ->
60-
mapM_ (processFile opts) =<< (lines <$> liftIO (readFile path))
60+
mapM_ (processFile opts) . lines =<< liftIO (readFile path)
6161
Nothing -> case filePaths opts of
6262
[] -> withNixContext Nothing Repl.main
6363
["-"] ->

main/Repl.hs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ completeFunc reversedPrev word
348348
-- Commands
349349
| reversedPrev == ":"
350350
= pure . listCompletion
351-
$ map helpOptionName (helpOptions :: HelpOptions e t f m)
351+
$ fmap helpOptionName (helpOptions :: HelpOptions e t f m)
352352

353353
-- Files
354354
| any (`Data.List.isPrefixOf` word) [ "/", "./", "../", "~/" ]
@@ -363,9 +363,7 @@ completeFunc reversedPrev word
363363
Nothing -> pure []
364364
Just binding -> do
365365
candidates <- lift $ algebraicComplete subFields binding
366-
pure
367-
$ map notFinished
368-
$ listCompletion (Data.Text.unpack . (var <>) <$> candidates)
366+
pure $ notFinished <$> listCompletion (Data.Text.unpack . (var <>) <$> candidates)
369367

370368
-- Builtins, context variables
371369
| otherwise
@@ -377,11 +375,11 @@ completeFunc reversedPrev word
377375

378376
pure $ listCompletion
379377
$ ["__includes"]
380-
++ (Data.Text.unpack <$> contextKeys)
381-
++ (Data.Text.unpack <$> shortBuiltins)
378+
<> (Data.Text.unpack <$> contextKeys)
379+
<> (Data.Text.unpack <$> shortBuiltins)
382380

383381
where
384-
listCompletion = map simpleCompletion . filter (word `Data.List.isPrefixOf`)
382+
listCompletion = fmap simpleCompletion . filter (word `Data.List.isPrefixOf`)
385383

386384
notFinished x = x { isFinished = False }
387385

@@ -401,7 +399,7 @@ completeFunc reversedPrev word
401399
Nothing -> pure []
402400
Just e ->
403401
demand e
404-
(\e' -> fmap (("." <> f) <>) <$> algebraicComplete fs e')
402+
(\e' -> (fmap . fmap) (("." <> f) <>) $ algebraicComplete fs e')
405403

406404
in case val of
407405
NVSet xs _ -> withMap xs
@@ -508,7 +506,7 @@ renderSetOptions :: [HelpSetOption] -> Doc ()
508506
renderSetOptions so =
509507
Prettyprinter.indent 4
510508
$ Prettyprinter.vsep
511-
$ flip map so
509+
$ flip fmap so
512510
$ \h ->
513511
Prettyprinter.pretty (helpSetOptionName h)
514512
<+> helpSetOptionSyntax h

src/Nix.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ evaluateExpression
107107
-> m a
108108
evaluateExpression mpath evaluator handler expr = do
109109
opts :: Options <- asks (view hasLens)
110-
args <- traverse (traverse eval') $ map (second parseArg) (arg opts) ++ map
110+
args <- traverse (traverse eval') $ fmap (second parseArg) (arg opts) ++ fmap
111111
(second mkStr)
112112
(argstr opts)
113113
evaluator mpath expr >>= \f -> demand f $ \f' ->

0 commit comments

Comments
 (0)