It took me the afternoon but I got a LSP working
This commit is contained in:
@@ -6,18 +6,17 @@ import Text.Read
|
||||
|
||||
|
||||
data Round = Round { red :: Int, green :: Int, blue :: Int }
|
||||
|
||||
data Game = Game { gid :: Int, rounds :: [Round] }
|
||||
|
||||
|
||||
parseCubes :: [String] -> Round -> Round
|
||||
parseCubes [] round = round
|
||||
parseCubes ((h: ' ': 'r': 'e': 'd': []): t) round = parseCubes t round {red = read [h]}
|
||||
parseCubes ((h1: h2: ' ': 'r': 'e': 'd': []): t) round = parseCubes t round {red = read [h1, h2]}
|
||||
parseCubes ((h: ' ': 'g': 'r': 'e': 'e': 'n': []): t) round = parseCubes t round {green = read [h]}
|
||||
parseCubes ((h1: h2: ' ': 'g': 'r': 'e': 'e': 'n': []): t) round = parseCubes t round {green = read [h1, h2]}
|
||||
parseCubes ((h: ' ': 'b': 'l': 'u': 'e': []): t) round = parseCubes t round {blue = read [h]}
|
||||
parseCubes ((h1: h2: ' ': 'b': 'l': 'u': 'e': []): t) round = parseCubes t round {blue = read [h1, h2]}
|
||||
parseCubes ([h, ' ', 'r', 'e', 'd']: t) round = parseCubes t round {red = read [h]}
|
||||
parseCubes ([h1, h2, ' ', 'r', 'e', 'd']: t) round = parseCubes t round {red = read [h1, h2]}
|
||||
parseCubes ([h, ' ', 'g', 'r', 'e', 'e', 'n']: t) round = parseCubes t round {green = read [h]}
|
||||
parseCubes ([h1, h2, ' ', 'g', 'r', 'e', 'e', 'n']: t) round = parseCubes t round {green = read [h1, h2]}
|
||||
parseCubes ([h, ' ', 'b', 'l', 'u', 'e']: t) round = parseCubes t round {blue = read [h]}
|
||||
parseCubes ([h1, h2, ' ', 'b', 'l', 'u', 'e']: t) round = parseCubes t round {blue = read [h1, h2]}
|
||||
|
||||
parseRound :: String -> Round
|
||||
parseRound roundRaw = parseCubes (split ", " roundRaw) Round {red = 0, green = 0, blue = 0}
|
||||
|
||||
Reference in New Issue
Block a user