Skip to content

Commit

Permalink
[#78] Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavsvejcar committed Sep 20, 2021
1 parent 2981afe commit ec3bedf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/Headroom/Command/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Headroom/IO/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec3bedf

Please sign in to comment.