From ec3bedfbcc9de8504bc7432eb03a19584d839905 Mon Sep 17 00:00:00 2001 From: Vaclav Svejcar Date: Mon, 20 Sep 2021 13:50:37 +0200 Subject: [PATCH] [#78] Minor code cleanup --- .hlint.yaml | 1 + src/Headroom/Command/Run.hs | 18 +++++++++--------- src/Headroom/IO/Network.hs | 3 +-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index 169cf0e..4aef73c 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -47,6 +47,7 @@ # - ignore: {name: Use const, within: SpecialModule} # Only within certain modules - ignore: { name: "Use newtype instead of data" } - ignore: { name: Redundant do, within: spec } +- ignore: {name: "Redundant lambda"} # Define some custom infix operators diff --git a/src/Headroom/Command/Run.hs b/src/Headroom/Command/Run.hs index d413afe..064d515 100644 --- a/src/Headroom/Command/Run.hs +++ b/src/Headroom/Command/Run.hs @@ -277,7 +277,7 @@ excludeIgnored paths = do Just repo -> filterM (fmap not . isIgnored repo) paths Nothing -> pure paths where - findRepo' = \dir -> do + findRepo' dir = do logInfo "Searching for VCS repository to extract exclude patterns from..." maybeRepo <- findRepo @_ @Git dir case maybeRepo of @@ -402,23 +402,23 @@ loadTemplateRefs refs = do refsWCtn <- mapM (loadContent fileSystem network) (filterPreferred refsWTp) M.fromList <$> mapM loadTemplate refsWCtn where - zipRs = \rs -> fmap (`zip` rs) . mapM getFileType $ rs - exts = toList $ templateExtensions @a - getAllRefs = \fs ref -> case ref of + zipRs rs = fmap (`zip` rs) . mapM getFileType $ rs + exts = toList $ templateExtensions @a + getAllRefs fs ref = case ref of LocalTemplateRef p -> fmap LocalTemplateRef <$> fsFindFilesByExts fs p exts _ -> pure [ref] - loadContent = \fs n (ft, ref) -> (ft, ref, ) <$> case ref of + loadContent fs n (ft, ref) = (ft, ref, ) <$> case ref of InlineRef content -> pure content LocalTemplateRef path -> fsLoadFile fs path UriTemplateRef uri -> decodeUtf8Lenient <$> nDownloadContent n uri BuiltInRef lt ft' -> pure $ licenseTemplate lt ft' - loadTemplate = \(ft, ref, T.strip -> c) -> (ft, ) <$> parseTemplate @a ref c - getFileType = \case + loadTemplate (ft, ref, T.strip -> c) = (ft, ) <$> parseTemplate @a ref c + getFileType = \case InlineRef _ -> pure Nothing BuiltInRef _ ft -> pure . Just $ ft other -> typeOfTemplate . T.unpack . renderRef $ other - filterPreferred rs = - mapMaybe (L.headMaybe . L.sort) . L.groupBy (\x y -> fst x == fst y) $ rs + filterPreferred = + mapMaybe (L.headMaybe . L.sort) . L.groupBy (\x y -> fst x == fst y) loadTemplates :: ( Has CtConfiguration env diff --git a/src/Headroom/IO/Network.hs b/src/Headroom/IO/Network.hs index 97c4298..afc6518 100644 --- a/src/Headroom/IO/Network.hs +++ b/src/Headroom/IO/Network.hs @@ -97,8 +97,7 @@ httpGet uri = do case eitherRes of Left err -> handleHttpException uri err Right res -> pure res - where - doGet = \u -> try @_ @HttpException $ req GET u NoReqBody bsResponse mempty + where doGet u = try @_ @HttpException $ req GET u NoReqBody bsResponse mempty handleHttpException :: MonadThrow m => URI -> HttpException -> m BsResponse