on master help sign in
Deduplicate isMaybe
5cce77aBryan O'Sullivan
Data/Aeson/TH.hs+4−6
@@ -355,9 +355,6 @@ argsToValue opts multiCons (RecC conName ts) = case (unwrapUnaryRecords opts, no
355
355
356 (maybes, rest) = partition isMaybe argCons
356 (maybes, rest) = partition isMaybe argCons
357
357
358− isMaybe (_, (_, _, AppT (ConT t) _)) = t == ''Maybe
359− isMaybe _ = False
360−
361 maybeToPair (arg, (field, _, _)) =
358 maybeToPair (arg, (field, _, _)) =
362 infixApp (infixE (Just $ toFieldName field)
359 infixApp (infixE (Just $ toFieldName field)
363 [|(.=)|]
360 [|(.=)|]
@@ -408,6 +405,10 @@ argsToValue opts multiCons (InfixC _ conName _) = do
408argsToValue opts multiCons (ForallC _ _ con) =
405argsToValue opts multiCons (ForallC _ _ con) =
409 argsToValue opts multiCons con
406 argsToValue opts multiCons con
410
407
408+isMaybe :: (a, (b, c, Type)) -> Bool
409+isMaybe (_, (_, _, AppT (ConT t) _)) = t == ''Maybe
410+isMaybe _ = False
411+
411(<^>) :: ExpQ -> ExpQ -> ExpQ
412(<^>) :: ExpQ -> ExpQ -> ExpQ
412(<^>) a b = infixApp a [|(<>)|] b
413(<^>) a b = infixApp a [|(<>)|] b
413infixr 6 <^>
414infixr 6 <^>
@@ -489,9 +490,6 @@ argsToEncoding opts multiCons (RecC conName ts) = case (unwrapUnaryRecords opts,
489
490
490 (maybes, rest) = partition isMaybe argCons
491 (maybes, rest) = partition isMaybe argCons
491
492
492− isMaybe (_, (_, _, AppT (ConT t) _)) = t == ''Maybe
493− isMaybe _ = False
494−
495 maybeToPair (arg, (field, _, _)) =
493 maybeToPair (arg, (field, _, _)) =
496 infixApp (infixE (Just $ toFieldName field)
494 infixApp (infixE (Just $ toFieldName field)
497 [|(.=)|]
495 [|(.=)|]