Play with syntax
This commit is contained in:
@@ -16,10 +16,10 @@ parseCubes ([h, "green"]: t) round = parseCubes t round {green = read h}
|
||||
parseCubes ([h, "blue"]: t) round = parseCubes t round {blue = read h}
|
||||
|
||||
parseRound :: String -> Round
|
||||
parseRound roundRaw = parseCubes (map words (split ", " roundRaw)) Round {red = 0, green = 0, blue = 0}
|
||||
parseRound roundRaw = parseCubes (map words $ split ", " roundRaw) Round {red = 0, green = 0, blue = 0}
|
||||
|
||||
parseRounds :: String -> [Round]
|
||||
parseRounds roundsRaw = map parseRound (split "; " roundsRaw)
|
||||
parseRounds roundsRaw = map parseRound $ split "; " roundsRaw
|
||||
|
||||
parseGameId :: String -> String
|
||||
parseGameId ('G': 'a': 'm': 'e': ' ': t) = parseGameId t
|
||||
@@ -28,7 +28,7 @@ parseGameId [] = []
|
||||
|
||||
parseGame :: String -> Game
|
||||
parseGame line = let (h: t: _) = split ": " line
|
||||
in Game {gid = read (parseGameId h), rounds = parseRounds t}
|
||||
in Game {gid = read . parseGameId $ h, rounds = parseRounds t}
|
||||
|
||||
parse :: IO [Game]
|
||||
parse = do done <- isEOF
|
||||
@@ -37,4 +37,4 @@ parse = do done <- isEOF
|
||||
else do line <- getLine
|
||||
let game = parseGame line
|
||||
otherGames <- parse
|
||||
return (game: otherGames)
|
||||
return $ game: otherGames
|
||||
|
||||
Reference in New Issue
Block a user