Refactor to use wildcard
This commit is contained in:
parent
bd4d350e76
commit
c25b6062c6
@ -16,6 +16,7 @@ executable aoc
|
||||
NoFieldSelectors
|
||||
OverloadedRecordDot
|
||||
OverloadedStrings
|
||||
RecordWildCards
|
||||
ViewPatterns
|
||||
ghc-options:
|
||||
-Wall
|
||||
|
||||
@ -29,18 +29,18 @@ main =
|
||||
]
|
||||
|
||||
puzzleTest :: Puzzle a -> TestTree
|
||||
puzzleTest p =
|
||||
puzzleTest Puzzle{..} =
|
||||
testGroup pt $
|
||||
["examples", "real"] <&> \t ->
|
||||
withResource (parseFile $ "inputs/" <> t <> "/" <> pt) mempty \input ->
|
||||
testGroup t $
|
||||
zip (map show [1 :: Int ..]) p.parts <&> \(n, pp) ->
|
||||
zip (map show [1 :: Int ..]) parts <&> \(n, pp) ->
|
||||
goldenVsString n ("outputs/" <> t <> "/" <> pt <> "/" <> n) $
|
||||
BL.fromStrict . encodeUtf8 . pp <$> input
|
||||
where
|
||||
pt = show p.number
|
||||
pt = show number
|
||||
parseFile fp =
|
||||
either (fail . ("parse failure: " <>) . errorBundlePretty) pure . runParser (p.parser <* eof) fp
|
||||
either (fail . ("parse failure: " <>) . errorBundlePretty) pure . runParser (parser <* eof) fp
|
||||
=<< T.readFile fp
|
||||
|
||||
data Puzzle input = Puzzle
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user