From f213cdb6c353a1fcddd66a03b986bd545c2baeb2 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Tue, 6 Jan 2026 17:39:18 +0000 Subject: [PATCH] Minor refactor --- haskell/Main.hs | 2 +- haskell/Pre.hs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/haskell/Main.hs b/haskell/Main.hs index 5c8098a..e077d31 100644 --- a/haskell/Main.hs +++ b/haskell/Main.hs @@ -43,7 +43,7 @@ main = . runParser (parser isRealData <* eof) fp =<< T.readFile fp let (rs, os) = - (lookupHList (fst . getCompose) &&& foldHListF (flip withConstrained HConsC . snd . getCompose) HNilC) $ + (lookupHList (fst . getCompose) &&& foldHListF (withConstrained HConsC . snd . getCompose) HNilC) $ mapHListF (\(Compose (Fanout (f, Op o))) -> Compose $ (o &&& id) $ f input) parts in pure (input, rs, os) ) diff --git a/haskell/Pre.hs b/haskell/Pre.hs index b133af1..9c30f62 100644 --- a/haskell/Pre.hs +++ b/haskell/Pre.hs @@ -161,10 +161,10 @@ sortPair (a, b) = if a <= b then (a, b) else (b, a) type PuzzleParts input = HListF (Compose (Fanout ((->) input) (Op Text)) (Constrained NFData)) infixr 9 /\\ (/\\) :: (NFData output) => (input -> output, output -> Text) -> PuzzleParts input outputs -> PuzzleParts input (output : outputs) -(/\\) (f, o) = HConsF $ Compose $ Fanout (Constrained . f, Op $ flip withConstrained o) +(/\\) (f, o) = HConsF $ Compose $ Fanout (Constrained . f, Op $ withConstrained o) infixr 9 /\ (/\) :: (Show output, NFData output) => (input -> output) -> PuzzleParts input outputs -> PuzzleParts input (output : outputs) -(/\) f = HConsF $ Compose $ Fanout (Constrained . f, Op $ flip withConstrained T.show) +(/\) f = HConsF $ Compose $ Fanout (Constrained . f, Op $ withConstrained T.show) nil :: PuzzleParts input '[] nil = HNilF @@ -211,8 +211,8 @@ lookupHList f = \case data Constrained c a where Constrained :: (c a) => a -> Constrained c a -withConstrained :: Constrained c a -> ((c a) => a -> b) -> b -withConstrained (Constrained x) f = f x +withConstrained :: ((c a) => a -> b) -> Constrained c a -> b +withConstrained f (Constrained x) = f x newtype Fanout f g a = Fanout (f a, g a)