Skip to content

Commit 4dd4255

Browse files
Zelenyamilesfrain
authored andcommitted
Remove all manual type class instance names
1 parent dcd88c6 commit 4dd4255

File tree

24 files changed

+133
-133
lines changed

24 files changed

+133
-133
lines changed

exercises/chapter10/src/Data/AddressBook.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ data PhoneType
2626
| OtherPhone
2727

2828
-- ANCHOR: PhoneType_generic
29-
derive instance genericPhoneType :: Generic PhoneType _
29+
derive instance Generic PhoneType _
3030

31-
instance encodeJsonPhoneType :: EncodeJson PhoneType where encodeJson = genericEncodeJson
32-
instance decodeJsonPhoneType :: DecodeJson PhoneType where decodeJson = genericDecodeJson
31+
instance EncodeJson PhoneType where encodeJson = genericEncodeJson
32+
instance DecodeJson PhoneType where decodeJson = genericDecodeJson
3333
-- ANCHOR_END: PhoneType_generic
34-
instance showPhoneType :: Show PhoneType where show = genericShow
34+
instance Show PhoneType where show = genericShow
3535

3636
type PhoneNumber
3737
= { "type" :: PhoneType

exercises/chapter10/test/no-peeking/Solutions.purs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ foreign import quadraticRootsSafeJson :: Json -> Json
6262
newtype WrapPair a
6363
= WrapPair (Pair a)
6464

65-
instance decodeJsonWrapPair :: DecodeJson a => DecodeJson (WrapPair a) where
65+
instance DecodeJson a => DecodeJson (WrapPair a) where
6666
decodeJson j = do
6767
decoded <- decodeJson j
6868
case decoded of
@@ -86,39 +86,39 @@ data Tree a
8686
= Leaf a
8787
| Branch (Tree a) (Tree a)
8888

89-
derive instance genericTree :: Generic (Tree a) _
89+
derive instance Generic (Tree a) _
9090

91-
instance encodeJsonTree :: EncodeJson a => EncodeJson (Tree a) where
91+
instance EncodeJson a => EncodeJson (Tree a) where
9292
encodeJson t = genericEncodeJson t
9393

94-
instance decodeJsonTree :: DecodeJson a => DecodeJson (Tree a) where
94+
instance DecodeJson a => DecodeJson (Tree a) where
9595
decodeJson t = genericDecodeJson t
9696

97-
instance eqTree :: Eq a => Eq (Tree a) where
97+
instance Eq a => Eq (Tree a) where
9898
eq t = genericEq t
9999

100-
instance showTree :: Show a => Show (Tree a) where
100+
instance Show a => Show (Tree a) where
101101
show t = genericShow t
102102

103103
data IntOrString
104104
= IntOrString_Int Int
105105
| IntOrString_String String
106106

107-
instance encodeJsonIntOrString :: EncodeJson IntOrString where
107+
instance EncodeJson IntOrString where
108108
encodeJson (IntOrString_Int i) = encodeJson i
109109
encodeJson (IntOrString_String s) = encodeJson s
110110

111-
instance decodeJsonIntOrString :: DecodeJson IntOrString where
111+
instance DecodeJson IntOrString where
112112
decodeJson j =
113113
foldr alt (Left $ TypeMismatch "Not Int or String")
114114
[ map IntOrString_Int $ decodeJson j
115115
, map IntOrString_String $ decodeJson j
116116
]
117117

118-
derive instance genericIntOrString :: Generic IntOrString _
118+
derive instance Generic IntOrString _
119119

120-
instance eqIntOrString :: Eq IntOrString where
120+
instance Eq IntOrString where
121121
eq = genericEq
122122

123-
instance showIntOrString :: Show IntOrString where
123+
instance Show IntOrString where
124124
show = genericShow

exercises/chapter11/src/Data/Coords.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ newtype Coords = Coords
77
, y :: Int
88
}
99

10-
instance showCoords :: Show Coords where
10+
instance Show Coords where
1111
show (Coords p) = "Coords " <>
1212
"{ x: " <> show p.x <>
1313
", y: " <> show p.y <>
1414
" }"
1515

16-
derive instance eqCoords :: Eq Coords
17-
derive instance ordCoords :: Ord Coords
16+
derive instance Eq Coords
17+
derive instance Ord Coords
1818

1919
coords :: Int -> Int -> Coords
2020
coords x y = Coords { x: x, y: y }

exercises/chapter11/src/Data/GameItem.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import Data.Maybe (Maybe(..))
88
data GameItem = Candle | Matches
99
-- ANCHOR_END: GameItem
1010

11-
instance showGameItem :: Show GameItem where
11+
instance Show GameItem where
1212
show Candle = "Candle"
1313
show Matches = "Matches"
1414

15-
derive instance eqGameItem :: Eq GameItem
16-
derive instance ordGameItem :: Ord GameItem
15+
derive instance Eq GameItem
16+
derive instance Ord GameItem
1717

1818
readItem :: String -> Maybe GameItem
1919
readItem "Candle" = Just Candle

exercises/chapter11/src/Data/GameState.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ newtype GameState = GameState
1818
}
1919
-- ANCHOR_END: GameState
2020

21-
instance showGameState :: Show GameState where
21+
instance Show GameState where
2222
show (GameState o) =
2323
"GameState " <>
2424
"{ items: " <> show o.items <>

exercises/chapter13/src/Sorted.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ newtype Sorted a = Sorted (Array a)
1010
sorted :: forall a. Sorted a -> Array a
1111
sorted (Sorted xs) = xs
1212

13-
instance showSorted :: Show a => Show (Sorted a) where
13+
instance Show a => Show (Sorted a) where
1414
show = show <<< sorted
1515

16-
instance arbSorted :: (Arbitrary a, Ord a) => Arbitrary (Sorted a) where
16+
instance (Arbitrary a, Ord a) => Arbitrary (Sorted a) where
1717
arbitrary = map (Sorted <<< sort) arbitrary

exercises/chapter13/src/Tree.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ data Tree a
99
= Leaf
1010
| Branch (Tree a) a (Tree a)
1111

12-
instance arbTree :: (Arbitrary a, Ord a) => Arbitrary (Tree a) where
12+
instance (Arbitrary a, Ord a) => Arbitrary (Tree a) where
1313
arbitrary = map fromArray arbitrary
1414

15-
instance coarbTree :: (Coarbitrary a) => Coarbitrary (Tree a) where
15+
instance (Coarbitrary a) => Coarbitrary (Tree a) where
1616
coarbitrary Leaf = identity
1717
coarbitrary (Branch l a r) =
1818
coarbitrary l <<<

exercises/chapter14/src/Data/DOM/Free.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ data ContentF a
4242
= TextContent String a
4343
| ElementContent Element a
4444

45-
instance functorContentF :: Functor ContentF where
45+
instance Functor ContentF where
4646
map f (TextContent s x) = TextContent s (f x)
4747
map f (ElementContent e x) = ElementContent e (f x)
4848

@@ -71,10 +71,10 @@ elem e = liftF $ ElementContent e unit
7171
class IsValue a where
7272
toValue :: a -> String
7373

74-
instance stringIsValue :: IsValue String where
74+
instance IsValue String where
7575
toValue = identity
7676

77-
instance intIsValue :: IsValue Int where
77+
instance IsValue Int where
7878
toValue = show
7979

8080
attribute :: forall a. IsValue a => AttributeKey a -> a -> Attribute

exercises/chapter14/src/Data/DOM/Name.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ data ContentF a
5050
| ElementContent Element a
5151
| NewName (Name -> a)
5252

53-
instance functorContentF :: Functor ContentF where
53+
instance Functor ContentF where
5454
map f (TextContent s x) = TextContent s (f x)
5555
map f (ElementContent e x) = ElementContent e (f x)
5656
map f (NewName k) = NewName (f <<< k)
@@ -79,13 +79,13 @@ newName = liftF $ NewName identity
7979
class IsValue a where
8080
toValue :: a -> String
8181

82-
instance stringIsValue :: IsValue String where
82+
instance IsValue String where
8383
toValue = identity
8484

85-
instance intIsValue :: IsValue Int where
85+
instance IsValue Int where
8686
toValue = show
8787

88-
instance nameIsValue :: IsValue Name where
88+
instance IsValue Name where
8989
toValue (Name n) = n
9090

9191
attribute :: forall a. IsValue a => AttributeKey a -> a -> Attribute
@@ -109,7 +109,7 @@ data Href
109109
= URLHref String
110110
| AnchorHref Name
111111

112-
instance hrefIsValue :: IsValue Href where
112+
instance IsValue Href where
113113
toValue (URLHref url) = url
114114
toValue (AnchorHref (Name nm)) = "#" <> nm
115115

exercises/chapter14/src/Data/DOM/Phantom.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ elem = ElementContent
6161
class IsValue a where
6262
toValue :: a -> String
6363

64-
instance stringIsValue :: IsValue String where
64+
instance IsValue String where
6565
toValue = identity
6666

67-
instance intIsValue :: IsValue Int where
67+
instance IsValue Int where
6868
toValue = show
6969

7070
attribute :: forall a. IsValue a => AttributeKey a -> a -> Attribute

0 commit comments

Comments
 (0)