parent
55668d6d02
commit
12441c70df
3 changed files with 1065 additions and 1 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,55 @@ |
||||
{-# LANGUAGE OverloadedStrings #-} |
||||
|
||||
module Day4 (day4) where |
||||
|
||||
import Control.Applicative ((<|>)) |
||||
import Control.Monad (void) |
||||
import qualified Data.Attoparsec.Text as P |
||||
|
||||
-- import qualified Data.Text as T |
||||
-- import qualified Data.Vector as V |
||||
-- import Numeric.Natural (Natural) |
||||
|
||||
type BYR = String |
||||
|
||||
type IYR = String |
||||
|
||||
type EYR = String |
||||
|
||||
type HGT = String |
||||
|
||||
type HCL = String |
||||
|
||||
type ECL = String |
||||
|
||||
type PID = String |
||||
|
||||
type CID = String |
||||
|
||||
data Passport = Passport |
||||
{ byr :: BYR, |
||||
iyr :: IYR, |
||||
eyr :: EYR, |
||||
hgt :: HGT, |
||||
hcl :: HCL, |
||||
ecl :: ECL, |
||||
pid :: PID, |
||||
cid :: Maybe CID -- Definitely not a hack! |
||||
} |
||||
deriving (Eq, Show) |
||||
|
||||
parsePassport :: P.Parser Passport |
||||
parsePassport = do |
||||
-- parse pairs |
||||
pairs <- parsePair `P.sepBy` (void P.space <|> P.endOfLine) |
||||
undefined |
||||
|
||||
parsePair :: P.Parser (String, String) |
||||
parsePair = do |
||||
key <- P.count 3 P.letter |
||||
_ <- P.char ':' |
||||
value <- P.many1 P.anyChar |
||||
return (key, value) |
||||
|
||||
day4 :: IO () |
||||
day4 = putStrLn "Day 4" |
Loading…
Reference in new issue