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 -8
View File
@@ -18,7 +18,7 @@ import Control.Monad (unless)
import Data.ByteString.Lazy (ByteString)
import Data.Function ((&))
import qualified Data.List.NonEmpty as NE
import Data.Maybe (catMaybes)
import Data.Maybe (catMaybes, fromMaybe)
import Data.Ratio (denominator, numerator)
import Data.Text (Text)
import qualified Data.Text as T
@@ -46,7 +46,7 @@ showQuantity q =
1 -> T.pack (show (numerator amt))
_ -> T.pack (show (toDouble amt))
prefix = if quantityFixed q then "=" else ""
unit = maybe "" (\u -> "%" <> u) (quantityUnit q)
unit = maybe "" ("%" <>) (quantityUnit q)
in prefix <> amount <> unit
-- ---------------------------------------------------------------------------
@@ -93,7 +93,7 @@ indexPage recipes =
let bad = filter (isLeft . Idx.riRecipe) recipes
unless (null bad) $ do
H.h3 "Unparseable recipes"
H.ul $ mapM_ (\r -> H.li $ H.toHtml (Idx.riTitle r)) bad
H.ul $ mapM_ (H.li . H.toHtml . Idx.riTitle) bad
-- | Render a single recipe link on the index page.
recipeItem :: FilePath -> Html
@@ -134,10 +134,7 @@ renderRecipe recipe = do
-- | Extract display title from recipe metadata or fallback.
titleText :: Recipe -> Text
titleText recipe =
case metaTitle (recipeMetadata recipe) of
Just t -> t
Nothing -> "Untitled Recipe"
titleText recipe = fromMaybe "Untitled Recipe" (metaTitle (recipeMetadata recipe))
-- ---------------------------------------------------------------------------
-- Metadata
@@ -179,7 +176,7 @@ showDuration d =
amount = case denominator amt of
1 -> T.pack (show (numerator amt))
_ -> T.pack (show (toDouble amt))
unit = maybe "" Prelude.id (durationUnit d)
unit = fromMaybe "" (durationUnit d)
in T.strip (amount <> " " <> unit)
-- | Roughly convert Rational to Double for display.