on master help sign in
fix hlint suggestions
commitd28a5dd7e31a1a7a6d8d50d53251468292ce16de authorAgentM <agentm@themactionfaction.com> dateFri 22 Dec 2017, 22:14 (9 years ago) parent91a357a
2 files changed+12−14
src/lib/ProjectM36/Tupleable.hs+4−6 test/Relation/Tupleable.hs+8−8
src/lib/ProjectM36/Tupleable.hs+4−6
@@ -111,12 +111,10 @@ toDeleteExpr rvName keyAttrs val = validateAttributes (S.fromList keyAttrs) expe
111111 expectedAttrSet = attributeNameSet (toAttributes (Proxy :: Proxy a))
112112
113113validateAttributes :: S.Set AttributeName -> S.Set AttributeName -> a -> Either RelationalError a
114−validateAttributes actualAttrs expectedAttrs val = if S.null actualAttrs then
115− Left EmptyAttributesError
116− else if not (S.null nonMatchingAttrs) then
117− Left (NoSuchAttributeNamesError nonMatchingAttrs)
118− else
119− Right val
114+validateAttributes actualAttrs expectedAttrs val
115+ | S.null actualAttrs = Left EmptyAttributesError
116+ | not (S.null nonMatchingAttrs) = Left (NoSuchAttributeNamesError nonMatchingAttrs)
117+ | otherwise = Right val
120118 where
121119 nonMatchingAttrs = attributeNamesNotContained actualAttrs expectedAttrs
122120
test/Relation/Tupleable.hs+8−8
@@ -157,27 +157,27 @@ testUpdateExpr = TestCase $ do
157157 updateMap = M.fromList [("attr9B", NakedAtomExpr (TextAtom "b")),
158158 ("attr9C", NakedAtomExpr (DoubleAtom 5.5))]
159159 restriction = AttributeEqualityPredicate "attr9A" (NakedAtomExpr (IntegerAtom 5))
160− actual = toUpdateExpr "rv" ["attr9A"] (Test9C {attr9A = 5,
160+ actual = toUpdateExpr "rv" ["attr9A"] Test9C {attr9A = 5,
161161 attr9B = "b",
162− attr9C = 5.5})
162+ attr9C = 5.5}
163163
164164 assertEqual "update expr1" expected actual
165165
166166testUpdateExprEmptyAttrs :: Test
167167testUpdateExprEmptyAttrs = TestCase $ do
168168 let expected = Left EmptyAttributesError
169− actual = toUpdateExpr "rv" [] (Test9C {attr9A = 5,
169+ actual = toUpdateExpr "rv" [] Test9C {attr9A = 5,
170170 attr9B = "b",
171− attr9C = 5.5})
171+ attr9C = 5.5}
172172 assertEqual "update with empty attrs" expected actual
173173
174174testUpdateExprWrongAttr :: Test
175175testUpdateExprWrongAttr = TestCase $ do
176176 --currently, passing in the wrong attribute replaces the whole relvar with a single tuple- is this what we want?
177177 let expected = Left (NoSuchAttributeNamesError (S.singleton "nonexistentattr"))
178− actual = toUpdateExpr "rv" ["nonexistentattr"] (Test9C {attr9A = 5,
178+ actual = toUpdateExpr "rv" ["nonexistentattr"] Test9C {attr9A = 5,
179179 attr9B = "b",
180− attr9C = 5.5})
180+ attr9C = 5.5}
181181 assertEqual "update with wrong attr" expected actual
182182
183183testDeleteExpr :: Test
@@ -186,9 +186,9 @@ testDeleteExpr = TestCase $ do
186186 (NakedAtomExpr (IntegerAtom 5)))
187187 (AttributeEqualityPredicate "attr9B"
188188 (NakedAtomExpr (TextAtom "b")))))
189− actual = toDeleteExpr "rv" ["attr9A", "attr9B"] (Test9C {attr9A = 5,
189+ actual = toDeleteExpr "rv" ["attr9A", "attr9B"] Test9C {attr9A = 5,
190190 attr9B = "b",
191− attr9C = 5.5})
191+ attr9C = 5.5}
192192 assertEqual "delete expr" expected actual
193193
194194