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