@@ -50,10 +50,9 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
5050 execContentsFilesOrRepl =
5151 fromMaybe
5252 loadFromCliFilePathList
53- ( loadBinaryCacheFile <|>
53+ $ loadBinaryCacheFile <|>
5454 loadLiteralExpression <|>
5555 loadExpressionFromFile
56- )
5756 where
5857 -- | The base case: read expressions from the last CLI directive (@[FILE]@) listed on the command line.
5958 loadFromCliFilePathList :: StdIO
@@ -67,9 +66,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
6766 runRepl = withEmptyNixContext Repl. main
6867
6968 readExpressionFromStdin =
70- do
71- expr <- liftIO Text. getContents
72- processExpr expr
69+ processExpr =<< liftIO Text. getContents
7370
7471 processSeveralFiles :: [Path ] -> StdIO
7572 processSeveralFiles = traverse_ processFile
@@ -82,7 +79,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
8279 (\ (binaryCacheFile :: Path ) ->
8380 do
8481 let file = replaceExtension binaryCacheFile " nixc"
85- processCLIOptions (Just file) =<< liftIO (readCache binaryCacheFile)
82+ processCLIOptions (pure file) =<< liftIO (readCache binaryCacheFile)
8683 ) <$> readFrom
8784
8885 -- | The `--expr` option: read expression from the argument string
@@ -101,8 +98,8 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
10198 _fp -> readFile _fp
10299 ) <$> fromFile
103100
104- processExpr text = handleResult Nothing $ parseNixTextLoc text
105101 processExpr :: Text -> StdIO
102+ processExpr = handleResult mempty . parseNixTextLoc
106103
107104 withEmptyNixContext = withNixContext mempty
108105
@@ -124,10 +121,10 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
124121 expr' <- liftIO $ reduceExpr mpath expr
125122 either
126123 (\ err -> errorWithoutStackTrace $ " Type error: " <> ppShow err)
127- (\ ty -> liftIO $ putStrLn $ " Type of expression: " <>
128- ppShow ( maybeToMonoid $ Map. lookup @ VarName @ [Scheme ] " it" $ coerce ty)
124+ (liftIO . putStrLn . (<>) " Type of expression: " .
125+ ppShow . maybeToMonoid . Map. lookup @ VarName @ [Scheme ] " it" . coerce
129126 )
130- ( HM. inferTop mempty ( one ( " it" , stripAnnotation expr')))
127+ $ HM. inferTop mempty $ curry one " it" $ stripAnnotation expr'
131128
132129 -- liftIO $ putStrLn $ runST $
133130 -- runLintM opts . renderSymbolic =<< lint opts expr
@@ -145,10 +142,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
145142 withEmptyNixContext $
146143 bool
147144 Repl. main
148- (do
149- val <- nixEvalExprLoc (coerce mpath) expr
150- Repl. main' $ pure val
151- )
145+ ((Repl. main' . pure ) =<< nixEvalExprLoc (coerce mpath) expr)
152146 evaluate
153147 )
154148
@@ -185,23 +179,23 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
185179 | otherwise = printer'
186180 where
187181 printer'
188- | xml = go (stringIgnoreContext . toXML) normalForm
182+ | xml = fun (stringIgnoreContext . toXML) normalForm
189183 -- 2021-05-27: NOTE: With naive fix of the #941
190184 -- This is overall a naive printer implementation, as options should interact/respect one another.
191185 -- A nice question: "Should respect one another to what degree?": Go full combinator way, for which
192186 -- old Nix CLI is nototrious for (and that would mean to reimplement the old Nix CLI),
193187 -- OR: https://github.com/haskell-nix/hnix/issues/172 and have some sane standart/default behaviour for (most) keys.
194- | json = go (stringIgnoreContext . mempty . nvalueToJSONNixString) normalForm
195- | strict = go (show . prettyNValue) normalForm
196- | values = go (show . prettyNValueProv) removeEffects
197- | otherwise = go (show . prettyNValue) removeEffects
188+ | json = fun (stringIgnoreContext . mempty . nvalueToJSONNixString) normalForm
189+ | strict = fun (show . prettyNValue) normalForm
190+ | values = fun (show . prettyNValueProv) removeEffects
191+ | otherwise = fun (show . prettyNValue) removeEffects
198192 where
199- go
193+ fun
200194 :: (b -> Text )
201195 -> (a -> StandardIO b )
202196 -> a
203- go g f = liftIO . Text. putStrLn . g <=< f
204197 -> StdIO
198+ fun g f = liftIO . Text. putStrLn . g <=< f
205199
206200 findAttrs
207201 :: AttrSet StdVal
0 commit comments