parseCommands :: String -> [Command]
parseCommands s = cs
  where
    Right cs = parse commands "" s
    commands = command `sepEndBy` endOfLine
    command = Command <$> action <*> (space *> range)
    action = try turnOn <|> try turnOff <|> toggle
    turnOn = string "turn on" *> return TurnOn
    turnOff = string "turn off" *> return TurnOff
    toggle = string "toggle" *> return Toggle
    range = Range <$> coord <*> (string " through " *> coord)
    coord = (,) <$> num <*> (char ',' *> num)
    num = read <$> many1 digit
parseCommands :: String -> [Command]
parseCommands s = cs
  where
    Right cs = parse commands "" s
    commands = command `sepEndBy` endOfLine
    command = Command <$> action <*> (space *> range)
    action = try turnOn <|> try turnOff <|> toggle
    turnOn = string "turn on" *> return TurnOn
    turnOff = string "turn off" *> return TurnOff
    toggle = string "toggle" *> return Toggle
    range = Range <$> coord <*> (string " through " *> coord)
    coord = (,) <$> num <*> (char ',' *> num)
    num = read <$> many1 digit
parseCommands s = cs
  where
    Right cs = parse commands "" s
    commands = command `sepEndBy` endOfLine
    command = Command <$> action <*> (space *> range)
    action = try turnOn <|> try turnOff <|> toggle
    turnOn = string "turn on" *> return TurnOn
    turnOff = string "turn off" *> return TurnOff
    toggle = string "toggle" *> return Toggle
    range = Range <$> coord <*> (string " through " *> coord)
    coord = (,) <$> num <*> (char ',' *> num)
    num = read <$> many1 digit