diff --git a/.hlint.yaml b/.hlint.yaml index 95735a3ca8..3aac4d9b13 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -16,6 +16,7 @@ # custom rules: - hint: { lhs: (() <$), rhs: void } - hint: { lhs: return, rhs: pure } +- hint: { lhs: maybe mempty, rhs: foldMap } # We want the latter function because it handles signals properly. - error: { name: Use shutdown, lhs: runSettings, rhs: runSettingsWithShutdown } diff --git a/libs/wire-api/src/Wire/API/Call/Config.hs b/libs/wire-api/src/Wire/API/Call/Config.hs index 3777bdcbb7..4c45d67875 100644 --- a/libs/wire-api/src/Wire/API/Call/Config.hs +++ b/libs/wire-api/src/Wire/API/Call/Config.hs @@ -255,7 +255,7 @@ instance BC.ToByteString TurnURI where <> BC.builder h <> byteString ":" <> BC.builder p - <> maybe mempty ((byteString "?transport=" <>) . BC.builder) tp + <> foldMap ((byteString "?transport=" <>) . BC.builder) tp instance BC.FromByteString TurnURI where parser = BC.parser >>= either fail pure . parseTurnURI diff --git a/libs/wire-api/src/Wire/API/User/Profile.hs b/libs/wire-api/src/Wire/API/User/Profile.hs index 37b3557e31..f634fe7f08 100644 --- a/libs/wire-api/src/Wire/API/User/Profile.hs +++ b/libs/wire-api/src/Wire/API/User/Profile.hs @@ -185,7 +185,7 @@ instance Show Locale where show = Text.unpack . locToText locToText :: Locale -> Text -locToText (Locale l c) = lan2Text l <> maybe mempty (("-" <>) . con2Text) c +locToText (Locale l c) = lan2Text l <> foldMap (("-" <>) . con2Text) c parseLocale :: Text -> Maybe Locale parseLocale = hush . parseOnly localeParser diff --git a/libs/zauth/src/Data/ZAuth/Token.hs b/libs/zauth/src/Data/ZAuth/Token.hs index a4319822dc..50966b5310 100644 --- a/libs/zauth/src/Data/ZAuth/Token.hs +++ b/libs/zauth/src/Data/ZAuth/Token.hs @@ -339,7 +339,7 @@ writeHeader t = <> dot <> field "t" (t ^. typ) <> dot - <> field "l" (maybe mempty builder (t ^. tag)) + <> field "l" (foldMap builder (t ^. tag)) instance ToByteString Access where builder t = diff --git a/services/galley/src/Galley/API/Update.hs b/services/galley/src/Galley/API/Update.hs index 27b2d6c806..b085feabb3 100644 --- a/services/galley/src/Galley/API/Update.hs +++ b/services/galley/src/Galley/API/Update.hs @@ -1269,7 +1269,7 @@ unqualifyEndpoint loc f ignoreMissing reportMissing message = do qualifiedNewOtrNativePush = newOtrNativePush message, qualifiedNewOtrTransient = newOtrTransient message, qualifiedNewOtrNativePriority = newOtrNativePriority message, - qualifiedNewOtrData = maybe mempty fromBase64TextLenient (newOtrData message), + qualifiedNewOtrData = foldMap fromBase64TextLenient (newOtrData message), qualifiedNewOtrClientMismatchStrategy = clientMismatchStrategy } unqualify (tDomain loc) <$> f qualifiedMessage diff --git a/services/galley/src/Galley/Intra/Spar.hs b/services/galley/src/Galley/Intra/Spar.hs index e9429ca244..7d005d8585 100644 --- a/services/galley/src/Galley/Intra/Spar.hs +++ b/services/galley/src/Galley/Intra/Spar.hs @@ -47,4 +47,4 @@ lookupScimUserInfos uids = do method POST . paths ["i", "scim", "userinfos"] . json (UserSet $ Set.fromList uids) - pure $ maybe mempty scimUserInfos $ responseJsonMaybe response + pure $ foldMap scimUserInfos $ responseJsonMaybe response diff --git a/services/gundeck/test/unit/Native.hs b/services/gundeck/test/unit/Native.hs index 27fee4380d..0d99b69600 100644 --- a/services/gundeck/test/unit/Native.hs +++ b/services/gundeck/test/unit/Native.hs @@ -79,10 +79,10 @@ instance FromJSON SnsNotification where where parseApns t n = let apn = decodeStrict' (T.encodeUtf8 n) - in maybe mempty (pure . SnsNotification t . SnsApnsData) apn + in foldMap (pure . SnsNotification t . SnsApnsData) apn parseGcm n = let gcm = decodeStrict' (T.encodeUtf8 n) - in maybe mempty (pure . SnsNotification GCM . SnsGcmData) gcm + in foldMap (pure . SnsNotification GCM . SnsGcmData) gcm data SnsData = SnsGcmData !GcmData diff --git a/services/spar/test-integration/Test/MetricsSpec.hs b/services/spar/test-integration/Test/MetricsSpec.hs index ab6a87136b..32f2d845d1 100644 --- a/services/spar/test-integration/Test/MetricsSpec.hs +++ b/services/spar/test-integration/Test/MetricsSpec.hs @@ -37,7 +37,7 @@ spec = describe "metrics" . it "works" $ do _ <- call $ get (spar . path p1) _ <- call $ get (spar . path (p2 "316f1c18-2980-11e9-ab0b-ef604d1791b2")) _ <- call $ get (spar . path (p2 "60a7dda8-2980-11e9-b359-fb5b41565453")) - resp :: String <- call $ maybe mempty cs . responseBody <$> get (spar . path "i/metrics") + resp :: String <- call $ foldMap cs . responseBody <$> get (spar . path "i/metrics") -- FUTUREWORK: here we could parse the prometheus 'RegistrySample' and inspect it more -- thoroughly, but i'm not sure there is a parser. liftIO $ do