Skip to content

Commit 559d84f

Browse files
committed
{Eval,Pretty}: m use stripAnn
1 parent efffdfe commit 559d84f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Nix/Eval.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,4 +571,4 @@ evalContent
571571
:: MonadNixEval v m
572572
=> AnnF ann NExprF (m v)
573573
-> m v
574-
evalContent = eval . annotated . getCompose
574+
evalContent = eval . stripAnn

src/Nix/Pretty.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ mkNixDoc o d = NixDoc { withoutParens = d, rootOp = o, wasPath = False }
5353
-- behaves as if its root operator had a precedence higher than all
5454
-- other operators (including function application).
5555
simpleExpr :: Doc ann -> NixDoc ann
56-
simpleExpr = mkNixDoc (OperatorInfo minBound NAssocNone "simple expr")
56+
simpleExpr = mkNixDoc $ OperatorInfo minBound NAssocNone "simple expr"
5757

5858
pathExpr :: Doc ann -> NixDoc ann
5959
pathExpr d = (simpleExpr d) { wasPath = True }
@@ -195,7 +195,7 @@ prettyOriginExpr
195195
-> Doc ann
196196
prettyOriginExpr = withoutParens . go
197197
where
198-
go = exprFNixDoc . annotated . getCompose . fmap render
198+
go = exprFNixDoc . stripAnn . fmap render
199199

200200
render :: Maybe (NValue t f m) -> NixDoc ann
201201
render Nothing = simpleExpr "_"
@@ -235,8 +235,11 @@ exprFNixDoc = \case
235235
]
236236
where
237237
opInfo = getBinaryOperator op
238-
f x | associativity opInfo /= x = opInfo { associativity = NAssocNone }
239-
| otherwise = opInfo
238+
f x =
239+
bool
240+
opInfo
241+
(opInfo { associativity = NAssocNone })
242+
(associativity opInfo /= x)
240243
NUnary op r1 ->
241244
mkNixDoc
242245
opInfo

0 commit comments

Comments
 (0)