Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

Commit 4532097

Browse files
authored
Merge pull request #2 from purescript/fix-field-instances
Fix instances for record fields
2 parents 9f39010 + 71d2187 commit 4532097

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Data/Generic/Rep.purs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ instance genericEqArgument :: Eq a => GenericEq (Argument a) where
8686
instance genericEqRec :: GenericEq a => GenericEq (Rec a) where
8787
genericEq' (Rec a1) (Rec a2) = genericEq' a1 a2
8888

89-
instance genericEqField :: GenericEq a => GenericEq (Field name a) where
90-
genericEq' (Field a1) (Field a2) = genericEq' a1 a2
89+
instance genericEqField :: Eq a => GenericEq (Field name a) where
90+
genericEq' (Field a1) (Field a2) = a1 == a2
9191

9292
-- | A `Generic` implementation of the `eq` member from the `Eq` type class.
9393
genericEq :: forall a rep. (Generic a rep, GenericEq rep) => a -> a -> Boolean
@@ -123,8 +123,8 @@ instance genericOrdArgument :: Ord a => GenericOrd (Argument a) where
123123
instance genericOrdRec :: GenericOrd a => GenericOrd (Rec a) where
124124
genericCompare' (Rec a1) (Rec a2) = genericCompare' a1 a2
125125

126-
instance genericOrdField :: GenericOrd a => GenericOrd (Field name a) where
127-
genericCompare' (Field a1) (Field a2) = genericCompare' a1 a2
126+
instance genericOrdField :: Ord a => GenericOrd (Field name a) where
127+
genericCompare' (Field a1) (Field a2) = compare a1 a2
128128

129129
-- | A `Generic` implementation of the `compare` member from the `Ord` type class.
130130
genericCompare :: forall a rep. (Generic a rep, GenericOrd rep) => a -> a -> Ordering
@@ -152,8 +152,8 @@ instance genericSemigroupArgument :: Semigroup a => GenericSemigroup (Argument a
152152
instance genericSemigroupRec :: GenericSemigroup a => GenericSemigroup (Rec a) where
153153
genericAppend' (Rec a1) (Rec a2) = Rec (genericAppend' a1 a2)
154154

155-
instance genericSemigroupField :: GenericSemigroup a => GenericSemigroup (Field name a) where
156-
genericAppend' (Field a1) (Field a2) = Field (genericAppend' a1 a2)
155+
instance genericSemigroupField :: Semigroup a => GenericSemigroup (Field name a) where
156+
genericAppend' (Field a1) (Field a2) = Field (append a1 a2)
157157

158158
-- | A `Generic` implementation of the `append` member from the `Semigroup` type class.
159159
genericAppend :: forall a rep. (Generic a rep, GenericSemigroup rep) => a -> a -> a
@@ -177,8 +177,8 @@ instance genericMonoidArgument :: Monoid a => GenericMonoid (Argument a) where
177177
instance genericMonoidRec :: GenericMonoid a => GenericMonoid (Rec a) where
178178
genericMempty' = Rec genericMempty'
179179

180-
instance genericMonoidField :: GenericMonoid a => GenericMonoid (Field name a) where
181-
genericMempty' = Field genericMempty'
180+
instance genericMonoidField :: Monoid a => GenericMonoid (Field name a) where
181+
genericMempty' = Field mempty
182182

183183
-- | A `Generic` implementation of the `mempty` member from the `Monoid` type class.
184184
genericMempty :: forall a rep. (Generic a rep, GenericMonoid rep) => a

0 commit comments

Comments
 (0)