Skip to content

Commit 1b517a4

Browse files
authored
Simplify Context extension (#809)
* Simplify Context extension * nit: s/`fmap`/<$>/
1 parent a3b95b2 commit 1b517a4

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Nix/Context.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ data Context m t = Context
2020
}
2121

2222
instance Has (Context m t) (Scopes m t) where
23-
hasLens f (Context x y z w) = (\x' -> Context x' y z w) <$> f x
23+
hasLens f a = (\x -> a { scopes = x }) <$> f (scopes a)
2424

2525
instance Has (Context m t) SrcSpan where
26-
hasLens f (Context x y z w) = (\y' -> Context x y' z w) <$> f y
26+
hasLens f a = (\x -> a { source = x }) <$> f (source a)
2727

2828
instance Has (Context m t) Frames where
29-
hasLens f (Context x y z w) = (\z' -> Context x y z' w) <$> f z
29+
hasLens f a = (\x -> a { frames = x }) <$> f (frames a)
3030

3131
instance Has (Context m t) Options where
32-
hasLens f (Context x y z w) = (\w' -> Context x y z w') <$> f w
32+
hasLens f a = (\x -> a { options = x }) <$> f (options a)
3333

3434
newContext :: Options -> Context m t
3535
newContext = Context emptyScopes nullSpan []

src/Nix/Options.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ data Options = Options
99
, tracing :: Bool
1010
, thunks :: Bool
1111
, values :: Bool
12-
, scopes :: Bool
12+
, showScopes :: Bool
1313
, reduce :: Maybe FilePath
1414
, reduceSets :: Bool
1515
, reduceLists :: Bool
@@ -42,7 +42,7 @@ defaultOptions current = Options { verbose = ErrorsOnly
4242
, tracing = False
4343
, thunks = False
4444
, values = False
45-
, scopes = False
45+
, showScopes = False
4646
, reduce = Nothing
4747
, reduceSets = False
4848
, reduceLists = False

src/Nix/Render/Frame.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ renderEvalFrame level f = do
106106
opts :: Options <- asks (view hasLens)
107107
case f of
108108
EvaluatingExpr scope e@(Fix (Compose (Ann ann _))) -> do
109-
let scopeInfo | scopes opts = [pretty $ show scope]
109+
let scopeInfo | showScopes opts = [pretty $ show scope]
110110
| otherwise = []
111111
fmap (\x -> scopeInfo ++ [x])
112112
$ renderLocation ann

0 commit comments

Comments
 (0)