From e92cc2f0d36dbc3f0bd76b7a3f5de4102a11c159 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 8 Dec 2025 22:48:29 +0000 Subject: [PATCH] Minor refactors --- haskell/Pre.hs | 2 ++ haskell/Puzzles/Day8.hs | 4 +++- haskell/aoc.cabal | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/haskell/Pre.hs b/haskell/Pre.hs index 57c5d0a..d15ea39 100644 --- a/haskell/Pre.hs +++ b/haskell/Pre.hs @@ -11,6 +11,7 @@ module Pre ( module Data.Char, module Data.Foldable, module Data.Foldable1, + module Data.Function, module Data.Functor, module Data.List, module Data.List.Extra, @@ -57,6 +58,7 @@ import Data.Bool import Data.Char import Data.Foldable hiding (foldl1, foldr1, maximum, maximumBy, minimum, minimumBy) import Data.Foldable1 +import Data.Function import Data.Functor import Data.List (sortOn, tails, transpose) import Data.List.Extra (dropEnd, enumerate) diff --git a/haskell/Puzzles/Day8.hs b/haskell/Puzzles/Day8.hs index 85fc933..20193fc 100644 --- a/haskell/Puzzles/Day8.hs +++ b/haskell/Puzzles/Day8.hs @@ -2,6 +2,7 @@ module Puzzles.Day8 (puzzle) where import Pre +import Control.Lens import Data.DisjointSet qualified as DS import Data.Text.Lazy qualified as TL import Linear.Metric @@ -27,7 +28,8 @@ puzzle = . connectBoxes , uncurry . const $ TL.show - . maybe (error "sets never unified") (\((V3 x1 _ _, V3 x2 _ _), _) -> x1 * x2) + . uncurry ((*) `on` view _x) + . maybe (error "sets never unified") fst . lastMay . takeWhile ((> 1) . DS.sets . snd) . connectBoxes diff --git a/haskell/aoc.cabal b/haskell/aoc.cabal index bacc80f..b3d8e71 100644 --- a/haskell/aoc.cabal +++ b/haskell/aoc.cabal @@ -48,6 +48,7 @@ executable aoc exceptions, extra, filepath, + lens, linear, massiv, megaparsec,