@@ -111,10 +111,8 @@ data NExprF r
111111 -- as @NSym "f"@ and @a@ as @NSym "a"@.
112112 | NList ! [r ]
113113 -- ^ A list literal.
114- | NSet ! [Binding r ]
115- -- ^ An attribute set literal, not recursive.
116- | NRecSet ! [Binding r ]
117- -- ^ An attribute set literal, recursive.
114+ | NSet ! NRecordType ! [Binding r ]
115+ -- ^ An attribute set literal
118116 | NLiteralPath ! FilePath
119117 -- ^ A path expression, which is evaluated to a store path. The path here
120118 -- can be relative, in which case it's evaluated relative to the file in
@@ -436,6 +434,16 @@ data NBinaryOp
436434instance Serialise NBinaryOp
437435#endif
438436
437+ data NRecordType
438+ = NNonRecursive
439+ | NRecursive
440+ deriving (Eq , Ord , Enum , Bounded , Generic , Typeable , Data , Show , Read ,
441+ NFData , Hashable )
442+
443+ #ifdef MIN_VERSION_serialise
444+ instance Serialise NRecordType
445+ #endif
446+
439447-- | Get the name out of the parameter (there might be none).
440448paramName :: Params r -> Maybe VarName
441449paramName (Param n ) = Just n
@@ -488,6 +496,7 @@ instance Binary a => Binary (Params a)
488496instance Binary NAtom
489497instance Binary NUnaryOp
490498instance Binary NBinaryOp
499+ instance Binary NRecordType
491500instance Binary a => Binary (NExprF a )
492501
493502instance (ToJSON v , ToJSON a ) => ToJSON (Antiquoted v a )
@@ -501,6 +510,7 @@ instance ToJSON a => ToJSON (Params a)
501510instance ToJSON NAtom
502511instance ToJSON NUnaryOp
503512instance ToJSON NBinaryOp
513+ instance ToJSON NRecordType
504514instance ToJSON a => ToJSON (NExprF a )
505515instance ToJSON NExpr
506516
@@ -515,6 +525,7 @@ instance FromJSON a => FromJSON (Params a)
515525instance FromJSON NAtom
516526instance FromJSON NUnaryOp
517527instance FromJSON NBinaryOp
528+ instance FromJSON NRecordType
518529instance FromJSON a => FromJSON (NExprF a )
519530instance FromJSON NExpr
520531
@@ -538,15 +549,15 @@ ekey
538549 => NonEmpty Text
539550 -> SourcePos
540551 -> Lens' (Fix g ) (Maybe (Fix g ))
541- ekey keys pos f e@ (Fix x) | (NSet xs, ann) <- fromNExpr x = case go xs of
552+ ekey keys pos f e@ (Fix x) | (NSet NNonRecursive xs, ann) <- fromNExpr x = case go xs of
542553 ((v, [] ) : _) -> fromMaybe e <$> f (Just v)
543554 ((v, r : rest) : _) -> ekey (r :| rest) pos f v
544555
545556 _ -> f Nothing <&> \ case
546557 Nothing -> e
547558 Just v ->
548559 let entry = NamedVar (NE. map StaticKey keys) v pos
549- in Fix (toNExpr (NSet (entry : xs), ann))
560+ in Fix (toNExpr (NSet NNonRecursive (entry : xs), ann))
550561 where
551562 go xs = do
552563 let keys' = NE. toList keys
@@ -563,8 +574,7 @@ ekey _ _ f e = fromMaybe e <$> f Nothing
563574stripPositionInfo :: NExpr -> NExpr
564575stripPositionInfo = transport phi
565576 where
566- phi (NSet binds ) = NSet (map go binds)
567- phi (NRecSet binds ) = NRecSet (map go binds)
577+ phi (NSet recur binds) = NSet recur (map go binds)
568578 phi (NLet binds body) = NLet (map go binds) body
569579 phi x = x
570580
0 commit comments