Skip to content

Commit 5c73148

Browse files
committed
Expr.Types: mv more instances into Orphans section
1 parent 9e87d0d commit 5c73148

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/Nix/Expr/Types.hs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,31 @@ import Instances.TH.Lift () -- importing Lift Text fo GH
6262

6363
-- Upstreaming so far was not pursued.
6464

65+
instance Serialise Pos where
66+
encode = Serialise.encode . unPos
67+
decode = mkPos <$> Serialise.decode
68+
69+
instance Serialise SourcePos where
70+
encode (SourcePos f l c) =
71+
Serialise.encode f <>
72+
Serialise.encode l <>
73+
Serialise.encode c
74+
decode =
75+
liftA3 SourcePos
76+
Serialise.decode
77+
Serialise.decode
78+
Serialise.decode
79+
80+
instance Hashable Pos where
81+
hashWithSalt salt = hashWithSalt salt . unPos
82+
83+
instance Hashable SourcePos where
84+
hashWithSalt salt (SourcePos f l c) =
85+
salt
86+
`hashWithSalt` f
87+
`hashWithSalt` l
88+
`hashWithSalt` c
89+
6590
instance Binary Pos where
6691
put = Binary.put . unPos
6792
get = mkPos <$> Binary.get
@@ -223,31 +248,6 @@ data NKeyName r
223248
, Show, Read, Hashable
224249
)
225250

226-
instance Serialise Pos where
227-
encode = Serialise.encode . unPos
228-
decode = mkPos <$> Serialise.decode
229-
230-
instance Serialise SourcePos where
231-
encode (SourcePos f l c) =
232-
Serialise.encode f <>
233-
Serialise.encode l <>
234-
Serialise.encode c
235-
decode =
236-
liftA3 SourcePos
237-
Serialise.decode
238-
Serialise.decode
239-
Serialise.decode
240-
241-
instance Hashable Pos where
242-
hashWithSalt salt = hashWithSalt salt . unPos
243-
244-
instance Hashable SourcePos where
245-
hashWithSalt salt (SourcePos f l c) =
246-
salt
247-
`hashWithSalt` f
248-
`hashWithSalt` l
249-
`hashWithSalt` c
250-
251251
instance NFData1 NKeyName where
252252
liftRnf _ (StaticKey !_ ) = ()
253253
liftRnf _ (DynamicKey (Plain !_) ) = ()

0 commit comments

Comments
 (0)