on master help sign in
Simplify some type signatures
commit08fa32a3c533a37780bea70ddc5c17073ba2f4cf authorBryan O'Sullivan <bos@serpentine.com> dateThu 2 Jul 2015, 15:49 (11 years ago) parent9d39e9d
2 files changed+18−20
tests/Encoders.hs+12−14 tests/Properties.hs+6−6
tests/Encoders.hs+12−14
@@ -84,47 +84,45 @@ gNullaryParseJSONObjectWithSingleField = genericParseJSON optsObjectWithSingleFi
8484-- SomeType encoders/decoders
8585--------------------------------------------------------------------------------
8686
87−type SomeTypeToJSON = SomeType Int -> Value
88−
89−thSomeTypeToJSON2ElemArray :: ToJSON a => SomeType a -> Value
87+thSomeTypeToJSON2ElemArray :: SomeType Int -> Value
9088thSomeTypeToJSON2ElemArray = $(mkToJSON opts2ElemArray ''SomeType)
9189
92−thSomeTypeParseJSON2ElemArray :: FromJSON a => Value -> Parser (SomeType a)
90+thSomeTypeParseJSON2ElemArray :: Value -> Parser (SomeType Int)
9391thSomeTypeParseJSON2ElemArray = $(mkParseJSON opts2ElemArray ''SomeType)
9492
9593
96−thSomeTypeToJSONTaggedObject :: ToJSON a => SomeType a -> Value
94+thSomeTypeToJSONTaggedObject :: SomeType Int -> Value
9795thSomeTypeToJSONTaggedObject = $(mkToJSON optsTaggedObject ''SomeType)
9896
99−thSomeTypeParseJSONTaggedObject :: FromJSON a => Value -> Parser (SomeType a)
97+thSomeTypeParseJSONTaggedObject :: Value -> Parser (SomeType Int)
10098thSomeTypeParseJSONTaggedObject = $(mkParseJSON optsTaggedObject ''SomeType)
10199
102100
103−thSomeTypeToJSONObjectWithSingleField :: ToJSON a => SomeType a -> Value
101+thSomeTypeToJSONObjectWithSingleField :: SomeType Int -> Value
104102thSomeTypeToJSONObjectWithSingleField = $(mkToJSON optsObjectWithSingleField ''SomeType)
105103
106−thSomeTypeParseJSONObjectWithSingleField :: FromJSON a => Value -> Parser (SomeType a)
104+thSomeTypeParseJSONObjectWithSingleField :: Value -> Parser (SomeType Int)
107105thSomeTypeParseJSONObjectWithSingleField = $(mkParseJSON optsObjectWithSingleField ''SomeType)
108106
109107
110−gSomeTypeToJSON2ElemArray :: ToJSON a => SomeType a -> Value
108+gSomeTypeToJSON2ElemArray :: SomeType Int -> Value
111109gSomeTypeToJSON2ElemArray = genericToJSON opts2ElemArray
112110
113−gSomeTypeParseJSON2ElemArray :: FromJSON a => Value -> Parser (SomeType a)
111+gSomeTypeParseJSON2ElemArray :: Value -> Parser (SomeType Int)
114112gSomeTypeParseJSON2ElemArray = genericParseJSON opts2ElemArray
115113
116114
117−gSomeTypeToJSONTaggedObject :: ToJSON a => SomeType a -> Value
115+gSomeTypeToJSONTaggedObject :: SomeType Int -> Value
118116gSomeTypeToJSONTaggedObject = genericToJSON optsTaggedObject
119117
120−gSomeTypeParseJSONTaggedObject :: FromJSON a => Value -> Parser (SomeType a)
118+gSomeTypeParseJSONTaggedObject :: Value -> Parser (SomeType Int)
121119gSomeTypeParseJSONTaggedObject = genericParseJSON optsTaggedObject
122120
123121
124−gSomeTypeToJSONObjectWithSingleField :: ToJSON a => SomeType a -> Value
122+gSomeTypeToJSONObjectWithSingleField :: SomeType Int -> Value
125123gSomeTypeToJSONObjectWithSingleField = genericToJSON optsObjectWithSingleField
126124
127−gSomeTypeParseJSONObjectWithSingleField :: FromJSON a => Value -> Parser (SomeType a)
125+gSomeTypeParseJSONObjectWithSingleField :: Value -> Parser (SomeType Int)
128126gSomeTypeParseJSONObjectWithSingleField = genericParseJSON optsObjectWithSingleField
129127
130128
tests/Properties.hs+6−6
@@ -173,13 +173,13 @@ tests = [
173173 ]
174174 ]
175175 , testGroup "SomeType" [
176− testProperty "2ElemArray" (is2ElemArray . (thSomeTypeToJSON2ElemArray :: SomeTypeToJSON))
177− , testProperty "TaggedObject" (isTaggedObject . (thSomeTypeToJSONTaggedObject :: SomeTypeToJSON))
178− , testProperty "ObjectWithSingleField" (isObjectWithSingleField . (thSomeTypeToJSONObjectWithSingleField :: SomeTypeToJSON))
176+ testProperty "2ElemArray" (is2ElemArray . thSomeTypeToJSON2ElemArray)
177+ , testProperty "TaggedObject" (isTaggedObject . thSomeTypeToJSONTaggedObject)
178+ , testProperty "ObjectWithSingleField" (isObjectWithSingleField . thSomeTypeToJSONObjectWithSingleField)
179179 , testGroup "roundTrip" [
180− testProperty "2ElemArray" (toParseJSON thSomeTypeParseJSON2ElemArray (thSomeTypeToJSON2ElemArray :: SomeTypeToJSON))
181− , testProperty "TaggedObject" (toParseJSON thSomeTypeParseJSONTaggedObject (thSomeTypeToJSONTaggedObject :: SomeTypeToJSON))
182− , testProperty "ObjectWithSingleField" (toParseJSON thSomeTypeParseJSONObjectWithSingleField (thSomeTypeToJSONObjectWithSingleField :: SomeTypeToJSON))
180+ testProperty "2ElemArray" (toParseJSON thSomeTypeParseJSON2ElemArray thSomeTypeToJSON2ElemArray)
181+ , testProperty "TaggedObject" (toParseJSON thSomeTypeParseJSONTaggedObject thSomeTypeToJSONTaggedObject)
182+ , testProperty "ObjectWithSingleField" (toParseJSON thSomeTypeParseJSONObjectWithSingleField thSomeTypeToJSONObjectWithSingleField)
183183 ]
184184 , testGroup "Approx" [
185185 testProperty "string" (isString . thApproxToJSONUnwrap)