Skip to content

Commit 40866b7

Browse files
committed
move instances HasCitations1 NValue to the parent
1 parent 598bac2 commit 40866b7

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/Nix/Cited.hs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import Lens.Family2.TH
1818

1919
import Nix.Expr.Types.Annotated
2020
import Nix.Scope
21+
import Nix.Value ( NValue, NValue'(NValue) )
22+
import Control.Monad.Free ( Free(Pure, Free) )
2123

2224
data Provenance m v = Provenance
2325
{ _lexicalScope :: Scopes m v
@@ -60,3 +62,15 @@ instance HasCitations m v (NCited m v a) where
6062
class HasCitations1 m v f where
6163
citations1 :: f a -> [Provenance m v]
6264
addProvenance1 :: Provenance m v -> f a -> f a
65+
66+
instance HasCitations1 m v f
67+
=> HasCitations m v (NValue' t f m a) where
68+
citations (NValue f) = citations1 f
69+
addProvenance x (NValue f) = NValue (addProvenance1 x f)
70+
71+
instance (HasCitations1 m v f, HasCitations m v t)
72+
=> HasCitations m v (NValue t f m) where
73+
citations (Pure t) = citations t
74+
citations (Free v) = citations v
75+
addProvenance x (Pure t) = Pure (addProvenance x t)
76+
addProvenance x (Free v) = Free (addProvenance x v)

src/Nix/Pretty.hs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,6 @@ prettyAtom atom = simpleExpr $ pretty $ unpack $ atomText atom
184184
prettyNix :: NExpr -> Doc ann
185185
prettyNix = withoutParens . foldFix exprFNixDoc
186186

187-
instance HasCitations1 m v f
188-
=> HasCitations m v (NValue' t f m a) where
189-
citations (NValue f) = citations1 f
190-
addProvenance x (NValue f) = NValue (addProvenance1 x f)
191-
192-
instance (HasCitations1 m v f, HasCitations m v t)
193-
=> HasCitations m v (NValue t f m) where
194-
citations (Pure t) = citations t
195-
citations (Free v) = citations v
196-
addProvenance x (Pure t) = Pure (addProvenance x t)
197-
addProvenance x (Free v) = Free (addProvenance x v)
198-
199187
prettyOriginExpr
200188
:: forall t f m ann
201189
. HasCitations1 m (NValue t f m) f

0 commit comments

Comments
 (0)