on master help sign in
hlint fixes
commit75627236a34c5a1cd64b79694f36cc3befd19a35 authorRyan Scott <ryan.gl.scott@gmail.com> dateSun 11 Jun 2017, 10:56 (9 years ago) parent02f6564
1 file changed+45−46
Data/Aeson/TH.hs+45−46
Data/Aeson/TH.hs+45−46
@@ -408,8 +408,8 @@ encStr opts = appE [|E.text|] . conTxt opts
408408
409409-- | If constructor is nullary.
410410isNullary :: ConstructorInfo -> Bool
411−isNullary (ConstructorInfo { constructorVariant = NormalConstructor
412− , constructorFields = tys }) = null tys
411+isNullary ConstructorInfo { constructorVariant = NormalConstructor
412+ , constructorFields = tys } = null tys
413413isNullary _ = False
414414
415415sumToValue :: Options -> Bool -> Bool -> Name -> Q Exp -> Q Exp
@@ -436,9 +436,9 @@ argsToValue :: JSONClass -> TyVarMap -> Options -> Bool -> ConstructorInfo -> Q
436436
437437-- Polyadic constructors with special case for unary constructors.
438438argsToValue jc tvMap opts multiCons
439− (ConstructorInfo { constructorName = conName
440− , constructorVariant = NormalConstructor
441− , constructorFields = argTys }) = do
439+ ConstructorInfo { constructorName = conName
440+ , constructorVariant = NormalConstructor
441+ , constructorFields = argTys } = do
442442 argTys' <- mapM resolveTypeSynonyms argTys
443443 let len = length argTys'
444444 args <- newNameList "arg" len
@@ -471,9 +471,9 @@ argsToValue jc tvMap opts multiCons
471471
472472-- Records.
473473argsToValue jc tvMap opts multiCons
474− info@(ConstructorInfo { constructorName = conName
475− , constructorVariant = RecordConstructor fields
476− , constructorFields = argTys }) =
474+ info@ConstructorInfo { constructorName = conName
475+ , constructorVariant = RecordConstructor fields
476+ , constructorFields = argTys } =
477477 case (unwrapUnaryRecords opts, not multiCons, argTys) of
478478 (True,True,[_]) -> argsToValue jc tvMap opts multiCons
479479 (info{constructorVariant = NormalConstructor})
@@ -533,9 +533,9 @@ argsToValue jc tvMap opts multiCons
533533
534534-- Infix constructors.
535535argsToValue jc tvMap opts multiCons
536− (ConstructorInfo { constructorName = conName
537− , constructorVariant = InfixConstructor
538− , constructorFields = argTys }) = do
536+ ConstructorInfo { constructorName = conName
537+ , constructorVariant = InfixConstructor
538+ , constructorFields = argTys } = do
539539 [alTy, arTy] <- mapM resolveTypeSynonyms argTys
540540 al <- newName "argL"
541541 ar <- newName "argR"
@@ -595,12 +595,11 @@ argsToEncoding :: JSONClass -> TyVarMap -> Options -> Bool -> ConstructorInfo ->
595595
596596-- Polyadic constructors with special case for unary constructors.
597597argsToEncoding jc tvMap opts multiCons
598− (ConstructorInfo { constructorName = conName
599− , constructorVariant = NormalConstructor
600− , constructorFields = argTys }) = do
598+ ConstructorInfo { constructorName = conName
599+ , constructorVariant = NormalConstructor
600+ , constructorFields = argTys } = do
601601 argTys' <- mapM resolveTypeSynonyms argTys
602− let len = length argTys'
603− args <- newNameList "arg" len
602+ args <- newNameList "arg" $ length argTys'
604603 js <- case zip args argTys' of
605604 -- Nullary constructors are converted to an empty array.
606605 [] -> return [| E.emptyArray_ |]
@@ -620,9 +619,9 @@ argsToEncoding jc tvMap opts multiCons
620619
621620-- Records.
622621argsToEncoding jc tvMap opts multiCons
623− info@(ConstructorInfo { constructorName = conName
624− , constructorVariant = RecordConstructor fields
625− , constructorFields = argTys }) = do
622+ info@ConstructorInfo { constructorName = conName
623+ , constructorVariant = RecordConstructor fields
624+ , constructorFields = argTys } =
626625 case (unwrapUnaryRecords opts, not multiCons, argTys) of
627626 (True,True,[_]) -> argsToEncoding jc tvMap opts multiCons
628627 (info{constructorVariant = NormalConstructor})
@@ -684,9 +683,9 @@ argsToEncoding jc tvMap opts multiCons
684683
685684-- Infix constructors.
686685argsToEncoding jc tvMap opts multiCons
687− (ConstructorInfo { constructorName = conName
688− , constructorVariant = InfixConstructor
689− , constructorFields = argTys }) = do
686+ ConstructorInfo { constructorName = conName
687+ , constructorVariant = InfixConstructor
688+ , constructorFields = argTys } = do
690689 al <- newName "argL"
691690 ar <- newName "argR"
692691 [alTy,arTy] <- mapM resolveTypeSynonyms argTys
@@ -910,9 +909,9 @@ consFromJSON jc tName opts vars cons = do
910909 (map (\x -> parseValue tvMap x conVal) cons')
911910
912911 parseValue _tvMap
913− (ConstructorInfo { constructorName = conName
914− , constructorVariant = NormalConstructor
915− , constructorFields = [] })
912+ ConstructorInfo { constructorName = conName
913+ , constructorVariant = NormalConstructor
914+ , constructorFields = [] }
916915 conVal = do
917916 str <- newName "str"
918917 caseE (varE conVal)
@@ -1093,32 +1092,32 @@ parseArgs :: JSONClass -- ^ The FromJSON variant being derived.
10931092 -> Q Exp
10941093-- Nullary constructors.
10951094parseArgs _ _ _ _
1096− (ConstructorInfo { constructorName = conName
1097− , constructorVariant = NormalConstructor
1098− , constructorFields = [] })
1095+ ConstructorInfo { constructorName = conName
1096+ , constructorVariant = NormalConstructor
1097+ , constructorFields = [] }
10991098 (Left _) =
11001099 [|pure|] `appE` conE conName
11011100parseArgs _ _ tName _
1102− (ConstructorInfo { constructorName = conName
1103− , constructorVariant = NormalConstructor
1104− , constructorFields = [] })
1101+ ConstructorInfo { constructorName = conName
1102+ , constructorVariant = NormalConstructor
1103+ , constructorFields = [] }
11051104 (Right valName) =
11061105 caseE (varE valName) $ parseNullaryMatches tName conName
11071106
11081107-- Unary constructors.
11091108parseArgs jc tvMap _ _
1110− (ConstructorInfo { constructorName = conName
1111− , constructorVariant = NormalConstructor
1112− , constructorFields = [argTy] })
1109+ ConstructorInfo { constructorName = conName
1110+ , constructorVariant = NormalConstructor
1111+ , constructorFields = [argTy] }
11131112 contents = do
11141113 argTy' <- resolveTypeSynonyms argTy
11151114 matchCases contents $ parseUnaryMatches jc tvMap argTy' conName
11161115
11171116-- Polyadic constructors.
11181117parseArgs jc tvMap tName _
1119− (ConstructorInfo { constructorName = conName
1120− , constructorVariant = NormalConstructor
1121− , constructorFields = argTys })
1118+ ConstructorInfo { constructorName = conName
1119+ , constructorVariant = NormalConstructor
1120+ , constructorFields = argTys }
11221121 contents = do
11231122 argTys' <- mapM resolveTypeSynonyms argTys
11241123 let len = genericLength argTys'
@@ -1126,16 +1125,16 @@ parseArgs jc tvMap tName _
11261125
11271126-- Records.
11281127parseArgs jc tvMap tName opts
1129− (ConstructorInfo { constructorName = conName
1130− , constructorVariant = RecordConstructor fields
1131− , constructorFields = argTys })
1128+ ConstructorInfo { constructorName = conName
1129+ , constructorVariant = RecordConstructor fields
1130+ , constructorFields = argTys }
11321131 (Left (_, obj)) = do
11331132 argTys' <- mapM resolveTypeSynonyms argTys
11341133 parseRecord jc tvMap argTys' opts tName conName fields obj
11351134parseArgs jc tvMap tName opts
1136− info@(ConstructorInfo { constructorName = conName
1137− , constructorVariant = RecordConstructor fields
1138− , constructorFields = argTys })
1135+ info@ConstructorInfo { constructorName = conName
1136+ , constructorVariant = RecordConstructor fields
1137+ , constructorFields = argTys }
11391138 (Right valName) =
11401139 case (unwrapUnaryRecords opts,argTys) of
11411140 (True,[_])-> parseArgs jc tvMap tName opts
@@ -1153,9 +1152,9 @@ parseArgs jc tvMap tName opts
11531152-- Infix constructors. Apart from syntax these are the same as
11541153-- polyadic constructors.
11551154parseArgs jc tvMap tName _
1156− (ConstructorInfo { constructorName = conName
1157− , constructorVariant = InfixConstructor
1158− , constructorFields = argTys })
1155+ ConstructorInfo { constructorName = conName
1156+ , constructorVariant = InfixConstructor
1157+ , constructorFields = argTys }
11591158 contents = do
11601159 argTys' <- mapM resolveTypeSynonyms argTys
11611160 matchCases contents $ parseProduct jc tvMap argTys' tName conName 2