Fix all hlint warnings

- Html.hs: replace lambdas with section/composition where possible
- Html.hs: replace case/fromMaybe with fromMaybe
- Html.hs: add fromMaybe to imports, use unqualified
- Parser.hs: replace span with break (2 locations)
- Parser.hs: replace if/then/else with list comprehension
- Parser.hs: remove redundant catch-all patterns (break is exhaustive)
- Server.hs: eta reduce htmlResponse
- Add .hlint.yaml to suppress 'Avoid lambda' (suggested fix has
  precedence issues with blaze-html's infix (!) operator)
- All 26 tests passing, hlint: No hints, exit code 0
This commit is contained in:
2026-05-19 07:25:59 -04:00
parent b775fd4f3f
commit 95a7521584
4 changed files with 16 additions and 17 deletions
+5 -7
View File
@@ -357,20 +357,18 @@ buildRecipe items =
groupSections :: [RawBlock] -> [Section]
groupSections [] = []
groupSections items =
case span (not . isSectionHeader) items of
case break isSectionHeader items of
-- No section header: everything goes into an unnamed section
(body, []) ->
[Section Nothing (makeNonEmpty (map rawToBody body))]
-- Items before the first header → unnamed section, then named
(before, (RawSectionHeader name) : rest) ->
let pre =
if null before
then []
else [Section Nothing (makeNonEmpty (map rawToBody before))]
[Section Nothing (makeNonEmpty (map rawToBody before))
| not (null before)
]
named = collectNamedSection name rest
in pre ++ named
-- Unreachable: 'span' never returns a non-header as the first item
-- of the second component, but GHC doesn't know that.
_ -> error "groupSections: impossible"
-- | Is this block a section header?
@@ -381,7 +379,7 @@ isSectionHeader _ = False
-- | Collect a named section: from the header to the next header (or end).
collectNamedSection :: Text -> [RawBlock] -> [Section]
collectNamedSection name items =
case span (not . isSectionHeader) items of
case break isSectionHeader items of
(body, []) ->
[Section (Just name) (makeNonEmpty (map rawToBody body))]
(body, (RawSectionHeader nextName) : rest) ->