diff --git a/haskell/Main.hs b/haskell/Main.hs index e98fd21..69175d2 100644 --- a/haskell/Main.hs +++ b/haskell/Main.hs @@ -3,7 +3,6 @@ module Main (main) where import Pre import Data.Functor.Contravariant -import Data.Functor.Identity import Data.Text.IO qualified as T import Puzzles.Day1 qualified as Day1 import Puzzles.Day10 qualified as Day10 @@ -42,7 +41,7 @@ main = describe pt do input <- liftIO $ parseFile $ "../inputs/" <> t <> "/" <> pt let (rs, os) = - ((unHListF . mapHListF (Const . fst)) &&& (fromHListF . mapHListF (Identity . snd))) $ + ((getConst . foldHListF (\x r -> Const $ fst x : getConst r) (Const [])) &&& foldHListF (HCons . snd) HNil) $ mapHListF (\(Fanout (f, Op o)) -> (o &&& id) $ f input) parts for_ (zip [1 :: Int ..] rs) $ uncurry $ \(show -> n) -> it n . pureGoldenTextFile ("../outputs/" <> t <> "/" <> pt <> "/" <> n) . (<> "\n") diff --git a/haskell/Pre.hs b/haskell/Pre.hs index 57e455b..e9969b1 100644 --- a/haskell/Pre.hs +++ b/haskell/Pre.hs @@ -44,8 +44,6 @@ module Pre ( HListF (..), foldHListF, mapHListF, - fromHListF, - unHListF, (/\), (/\\), nil, @@ -78,7 +76,6 @@ import Data.Foldable1 import Data.Function import Data.Functor import Data.Functor.Contravariant -import Data.Functor.Identity import Data.Kind (Type) import Data.List (List, sortOn, transpose) import Data.List.Extra (dropEnd, enumerate, firstJust, notNull, splitOn) @@ -158,12 +155,6 @@ foldHListF f e = \case mapHListF :: (forall a. f a -> g a) -> HListF f as -> HListF g as mapHListF t = foldHListF (\x r -> HConsF (t x) $ r) HNilF -fromHListF :: HListF Identity as -> HList as -fromHListF = foldHListF (\(Identity x) r -> HCons x r) HNil - -unHListF :: HListF (Const b) as -> List b -unHListF = getConst . foldHListF (\(Const x) (Const r) -> Const $ x : r) (Const []) - instance Semigroup (TestDefM a b ()) where (<>) = (>>) instance Monoid (TestDefM a b ()) where