1
0
Fork 0
advent-of-code/2022/haskell/src/Aoc.hs

12 lines
324 B
Haskell
Raw Normal View History

2022-12-04 09:33:47 -05:00
module Aoc (runReadP) where
import Text.ParserCombinators.ReadP
runReadP :: ReadP a -> String -> a
runReadP p s = unwrap $ readP_to_S p s
where
unwrap [(a, "")] = a
unwrap [(_, _rs)] = error "Parser did not consume entire stream."
unwrap (_:as) = unwrap as
unwrap _ = error "Parser error."