Skip to content

Commit 710d1d3

Browse files
committed
Expr.Types: m org
1 parent 559d84f commit 710d1d3

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

src/Nix/Expr/Shorthands.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ mkDots e [] = e
131131
mkDots (Fix (NSelect e keys' x)) keys =
132132
-- Special case: if the expression in the first argument is already
133133
-- a dotted expression, just extend it.
134-
Fix (NSelect e (keys' <> fmap (StaticKey ?? Nothing) keys) x)
135-
mkDots e keys = Fix $ NSelect e (fmap (StaticKey ?? Nothing) keys) Nothing
134+
Fix (NSelect e (keys' <> fmap (`StaticKey` Nothing) keys) x)
135+
mkDots e keys = Fix $ NSelect e (fmap (`StaticKey` Nothing) keys) Nothing
136136
-}
137137

138138
-- | An `inherit` clause without an expression to pull from.

src/Nix/Expr/Types.hs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,6 @@ instance TH.Lift NExpr where
532532
#endif
533533

534534

535-
-- ** @class NExprAnn@
536-
537-
class NExprAnn ann g | g -> ann where
538-
fromNExpr :: g r -> (NExprF r, ann)
539-
toNExpr :: (NExprF r, ann) -> g r
540-
541-
542535
-- ** Additional instances
543536

544537
$(deriveEq1 ''NExprF)
@@ -636,6 +629,31 @@ paramName :: Params r -> Maybe VarName
636629
paramName (Param n ) = pure n
637630
paramName (ParamSet _ _ n) = n
638631

632+
stripPositionInfo :: NExpr -> NExpr
633+
stripPositionInfo = transport phi
634+
where
635+
transport f (Fix x) = Fix $ transport f <$> f x
636+
637+
phi (NSet recur binds) = NSet recur $ go <$> binds
638+
phi (NLet binds body) = NLet (go <$> binds) body
639+
phi x = x
640+
641+
go (NamedVar path r _pos) = NamedVar path r nullPos
642+
go (Inherit ms names _pos) = Inherit ms names nullPos
643+
644+
nullPos :: SourcePos
645+
nullPos = SourcePos "<string>" (mkPos 1) (mkPos 1)
646+
647+
-- * Dead code
648+
649+
-- ** @class NExprAnn@
650+
651+
class NExprAnn ann g | g -> ann where
652+
fromNExpr :: g r -> (NExprF r, ann)
653+
toNExpr :: (NExprF r, ann) -> g r
654+
655+
-- ** Other
656+
639657
ekey
640658
:: NExprAnn ann g
641659
=> NonEmpty Text
@@ -671,18 +689,3 @@ ekey keys pos f e@(Fix x) | (NSet NNonRecursive xs, ann) <- fromNExpr x =
671689
ks
672690

673691
ekey _ _ f e = fromMaybe e <$> f Nothing
674-
675-
stripPositionInfo :: NExpr -> NExpr
676-
stripPositionInfo = transport phi
677-
where
678-
transport f (Fix x) = Fix $ transport f <$> f x
679-
680-
phi (NSet recur binds) = NSet recur $ go <$> binds
681-
phi (NLet binds body) = NLet (go <$> binds) body
682-
phi x = x
683-
684-
go (NamedVar path r _pos) = NamedVar path r nullPos
685-
go (Inherit ms names _pos) = Inherit ms names nullPos
686-
687-
nullPos :: SourcePos
688-
nullPos = SourcePos "<string>" (mkPos 1) (mkPos 1)

0 commit comments

Comments
 (0)