Skip to content

Commit e39221b

Browse files
committed
Builtins: m {clean-up, refactor}
1 parent 1b00b67 commit e39221b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/Nix/Builtins.hs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ instance
122122
)
123123
=> ToBuiltin t f m (a -> b) where
124124
toBuiltin name f =
125-
pure $ nvBuiltin name (toBuiltin name . f <=< fromValue . Deeper)
125+
pure $ nvBuiltin name $ toBuiltin name . f <=< fromValue . Deeper
126126

127127
-- *** @WValue@ closure wrapper to have @Ord@
128128

@@ -1071,7 +1071,7 @@ replaceStringsNix tfrom tto ts =
10711071
bugPassOneChar input output =
10721072
maybe
10731073
(finish updatedCtx output) -- The base case - there is no chars left to process -> finish
1074-
(\(c, i) -> go updatedCtx i (output <> Builder.singleton c)) -- If there are chars - pass one char & continue
1074+
(\(c, i) -> go updatedCtx i $ output <> Builder.singleton c) -- If there are chars - pass one char & continue
10751075
(Text.uncons input) -- chip first char
10761076

10771077
toValue $ go (getContext string) (stringIgnoreContext string) mempty
@@ -1204,7 +1204,7 @@ throwNix mnv =
12041204

12051205
importNix
12061206
:: forall e t f m . MonadNix e t f m => NValue t f m -> m (NValue t f m)
1207-
importNix = scopedImportNix (nvSet mempty mempty)
1207+
importNix = scopedImportNix $ nvSet mempty mempty
12081208

12091209
scopedImportNix
12101210
:: forall e t f m
@@ -1261,9 +1261,7 @@ sortNix comp = toValue <=< sortByM (cmp comp) <=< fromValue
12611261
(do
12621262
isGreaterThan <- (`callFunc` a) =<< callFunc f b
12631263
fromValue isGreaterThan <&>
1264-
bool
1265-
EQ
1266-
GT
1264+
bool EQ GT
12671265
)
12681266
(pure LT)
12691267
=<< fromValue isLessThan
@@ -1618,7 +1616,7 @@ currentSystemNix =
16181616
currentTimeNix :: MonadNix e t f m => m (NValue t f m)
16191617
currentTimeNix =
16201618
do
1621-
opts :: Options <- asks (view hasLens)
1619+
opts :: Options <- asks $ view hasLens
16221620
toValue @Integer $ round $ Time.utcTimeToPOSIXSeconds $ currentTime opts
16231621

16241622
derivationStrictNix :: MonadNix e t f m => NValue t f m -> m (NValue t f m)
@@ -1944,9 +1942,9 @@ builtins =
19441942
buildMap = fmap (M.fromList . fmap mapping) builtinsList
19451943
topLevelBuiltins = mapping <<$>> fullBuiltinsList
19461944

1947-
fullBuiltinsList = go <<$>> builtinsList
1945+
fullBuiltinsList = nameBuiltins <<$>> builtinsList
19481946
where
1949-
go b@(Builtin TopLevel _) = b
1950-
go (Builtin Normal (name, builtin)) =
1951-
Builtin TopLevel ("__" <> name, builtin)
1947+
nameBuiltins b@(Builtin TopLevel _) = b
1948+
nameBuiltins (Builtin Normal nB) =
1949+
Builtin TopLevel $ first ("__" <>) nB
19521950

0 commit comments

Comments
 (0)