@@ -19,7 +19,6 @@ import qualified Data.Text.IO as Text
1919import Text.Show.Pretty ( ppShow )
2020import Nix hiding ( force )
2121import Nix.Convert
22- import Nix.Fresh.Basic
2322import Nix.Json
2423import Nix.Options.Parser
2524import Nix.Standard
@@ -47,7 +46,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
4746 where
4847 -- 2021-07-15: NOTE: This logic should be weaved stronger through CLI options logic (OptParse-Applicative code)
4948 -- As this logic is not stated in the CLI documentation, for example. So user has no knowledge of these.
50- execContentsFilesOrRepl :: StandardT ( StdIdT IO ) ()
49+ execContentsFilesOrRepl :: StdIO
5150 execContentsFilesOrRepl =
5251 fromMaybe
5352 loadFromCliFilePathList
@@ -57,6 +56,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
5756 )
5857 where
5958 -- | The base case: read expressions from the last CLI directive (@[FILE]@) listed on the command line.
59+ loadFromCliFilePathList :: StdIO
6060 loadFromCliFilePathList =
6161 case filePaths of
6262 [] -> runRepl
@@ -71,12 +71,13 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
7171 expr <- liftIO Text. getContents
7272 processExpr expr
7373
74- processSeveralFiles :: [Path ] -> StandardT ( StdIdT IO ) ()
74+ processSeveralFiles :: [Path ] -> StdIO
7575 processSeveralFiles = traverse_ processFile
7676 where
7777 processFile path = handleResult (pure path) =<< parseNixFileLoc path
7878
7979 -- | The `--read` option: load expression from a serialized file.
80+ loadBinaryCacheFile :: Maybe StdIO
8081 loadBinaryCacheFile =
8182 (\ (binaryCacheFile :: Path ) ->
8283 do
@@ -85,9 +86,11 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
8586 ) <$> readFrom
8687
8788 -- | The `--expr` option: read expression from the argument string
89+ loadLiteralExpression :: Maybe StdIO
8890 loadLiteralExpression = processExpr <$> expression
8991
9092 -- | The `--file` argument: read expressions from the files listed in the argument file
93+ loadExpressionFromFile :: Maybe StdIO
9194 loadExpressionFromFile =
9295 -- We can start use Text as in the base case, requires changing Path -> Text
9396 -- But that is a gradual process:
@@ -99,6 +102,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
99102 ) <$> fromFile
100103
101104 processExpr text = handleResult Nothing $ parseNixTextLoc text
105+ processExpr :: Text -> StdIO
102106
103107 withEmptyNixContext = withNixContext mempty
104108
@@ -133,8 +137,8 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
133137 NixException frames ->
134138 errorWithoutStackTrace . show =<<
135139 renderFrames
136- @ ( StdValue ( StandardT ( StdIdT IO )))
137- @ ( StdThunk ( StandardT ( StdIdT IO )))
140+ @ StdVal
141+ @ StdThun
138142 frames
139143
140144 when repl $
@@ -149,7 +153,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
149153 )
150154
151155 -- 2021-07-15: NOTE: Logic of CLI Option processing is scattered over several functions, needs to be consolicated.
152- processCLIOptions :: Maybe Path -> NExprLoc -> StandardT ( StdIdT IO ) ()
156+ processCLIOptions :: Maybe Path -> NExprLoc -> StdIO
153157 processCLIOptions mpath expr
154158 | evaluate =
155159 if
@@ -174,7 +178,10 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
174178 evaluateExprWithEvaluator evaluator = evaluateExpression (coerce mpath) evaluator printer
175179
176180 printer
177- | finder = findAttrs <=< fromValue @ (AttrSet (StdValue (StandardT (StdIdT IO ))))
181+ :: StdVal
182+ -> StdIO
183+ printer
184+ | finder = findAttrs <=< fromValue @ (AttrSet StdVal )
178185 | otherwise = printer'
179186 where
180187 printer'
@@ -191,16 +198,17 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
191198 where
192199 go
193200 :: (b -> Text )
194- -> (a -> StandardT ( StdIdT IO ) b )
201+ -> (a -> StandardIO b )
195202 -> a
196- -> StandardT (StdIdT IO ) ()
197203 go g f = liftIO . Text. putStrLn . g <=< f
204+ -> StdIO
198205
199206 findAttrs
200- :: AttrSet ( StdValue ( StandardT ( StdIdT IO )))
201- -> StandardT ( StdIdT IO ) ()
207+ :: AttrSet StdVal
208+ -> StdIO
202209 findAttrs = go mempty
203210 where
211+ go :: Text -> AttrSet StdVal -> StdIO
204212 go prefix s =
205213 do
206214 xs <-
@@ -214,7 +222,7 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
214222 path = prefix <> k
215223 (_, descend) = filterEntry path k
216224
217- val <- readRef @ ( StandardT ( StdIdT IO )) ref
225+ val <- readRef @ StandardIO ref
218226 bool
219227 (pure Nothing )
220228 (forceEntry path nv)
@@ -267,10 +275,10 @@ main' opts@Options{..} = runWithBasicEffectsIO opts execContentsFilesOrRepl
267275 _ -> (True , True )
268276
269277 forceEntry
270- :: MonadValue a ( StandardT ( StdIdT IO ))
278+ :: MonadValue a StandardIO
271279 => Text
272280 -> a
273- -> StandardT ( StdIdT IO ) (Maybe a )
281+ -> StandardIO (Maybe a )
274282 forceEntry k v =
275283 catch
276284 (pure <$> demand v)
0 commit comments