Add non-parameterised version of HList fold
This commit is contained in:
parent
2180af71ad
commit
234640fb1a
@ -41,7 +41,7 @@ main =
|
||||
describe pt do
|
||||
input <- liftIO $ parseFile $ "../inputs/" <> t <> "/" <> pt
|
||||
let (rs, os) =
|
||||
((getConst . foldHListF (\x r -> Const $ fst x : getConst r) (Const [])) &&& foldHListF (HCons . snd) HNil) $
|
||||
(foldHListF0 ((:) . fst) [] &&& 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")
|
||||
|
||||
@ -43,6 +43,7 @@ module Pre (
|
||||
sortPair,
|
||||
HListF (..),
|
||||
foldHListF,
|
||||
foldHListF0,
|
||||
mapHListF,
|
||||
(/\),
|
||||
(/\\),
|
||||
@ -150,6 +151,10 @@ foldHListF :: (forall x xs. f x -> r xs -> r (x ': xs)) -> r '[] -> HListF f as
|
||||
foldHListF f e = \case
|
||||
HNilF -> e
|
||||
HConsF x xs -> f x $ foldHListF f e xs
|
||||
foldHListF0 :: (forall x. f x -> r -> r) -> r -> HListF f as -> r
|
||||
foldHListF0 f e = \case
|
||||
HNilF -> e
|
||||
HConsF x xs -> f x $ foldHListF0 f e xs
|
||||
mapHListF :: (forall a. f a -> g a) -> HListF f as -> HListF g as
|
||||
mapHListF t = foldHListF (\x r -> HConsF (t x) $ r) HNilF
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user