Set -Wall and cleanup warnings
I should have done this from the start.
This commit is contained in:
		
							parent
							
								
									6c0777aada
								
							
						
					
					
						commit
						334616392b
					
				
					 2 changed files with 11 additions and 9 deletions
				
			
		
							
								
								
									
										1
									
								
								assessments/dotted-squares/.ghci
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								assessments/dotted-squares/.ghci
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | ||||||
|  | :set -Wall | ||||||
|  | @ -78,8 +78,8 @@ digit = satisfy (\c -> c >= '0' && c <= '9') | ||||||
| int :: ReadP Int | int :: ReadP Int | ||||||
| int = read <$> many1 digit | int = read <$> many1 digit | ||||||
| 
 | 
 | ||||||
| line :: ReadP String | inputLine :: ReadP String | ||||||
| line = manyTill get (char '\n') | inputLine = manyTill get (char '\n') | ||||||
| 
 | 
 | ||||||
| direction :: ReadP Direction | direction :: ReadP Direction | ||||||
| direction = do | direction = do | ||||||
|  | @ -89,6 +89,7 @@ direction = do | ||||||
|     'R' -> pure DirRight |     'R' -> pure DirRight | ||||||
|     'U' -> pure DirUp |     'U' -> pure DirUp | ||||||
|     'D' -> pure DirDown |     'D' -> pure DirDown | ||||||
|  |     _   -> fail $ "Unexpected direction: " ++ show c | ||||||
| 
 | 
 | ||||||
| validMove :: Int -> Int -> ReadP Line | validMove :: Int -> Int -> ReadP Line | ||||||
| validMove w h = do | validMove w h = do | ||||||
|  | @ -97,7 +98,7 @@ validMove w h = do | ||||||
|   y <- int |   y <- int | ||||||
|   skipSpaces |   skipSpaces | ||||||
|   dir <- direction |   dir <- direction | ||||||
|   char '\n' |   _ <- char '\n' | ||||||
|   if x >= 0 && x <= w &&  y >= 0 && y <= h then do |   if x >= 0 && x <= w &&  y >= 0 && y <= h then do | ||||||
|     let beg = Point x y |     let beg = Point x y | ||||||
|     pure $ mkLine beg (shiftPoint dir beg) |     pure $ mkLine beg (shiftPoint dir beg) | ||||||
|  | @ -106,9 +107,9 @@ validMove w h = do | ||||||
| 
 | 
 | ||||||
| game :: ReadP Game | game :: ReadP Game | ||||||
| game = do | game = do | ||||||
|   w <- read <$> line :: ReadP Int |   w <- read <$> inputLine | ||||||
|   h <- read <$> line :: ReadP Int |   h <- read <$> inputLine | ||||||
|   locs <- read <$> line :: ReadP Int |   locs <- read <$> inputLine | ||||||
|   moves <- count locs (validMove w h) |   moves <- count locs (validMove w h) | ||||||
|   eof |   eof | ||||||
|   pure $ Game mempty moves |   pure $ Game mempty moves | ||||||
|  | @ -157,7 +158,7 @@ doRotateLine Vertical   End CW  (Line _ end) = mkLineDir' end DirLeft | ||||||
| doRotateLine Vertical   End CCW (Line _ end) = mkLineDir' end DirRight | doRotateLine Vertical   End CCW (Line _ end) = mkLineDir' end DirRight | ||||||
| 
 | 
 | ||||||
| classifyOrientation :: Line -> Orientation | classifyOrientation :: Line -> Orientation | ||||||
| classifyOrientation (Line (Point x1 y1) (Point x2 y2)) = | classifyOrientation (Line (Point _ y1) (Point _ y2)) = | ||||||
|   if y1 == y2 then Horizontal else Vertical |   if y1 == y2 then Horizontal else Vertical | ||||||
| 
 | 
 | ||||||
| closesAnySquare :: HS.HashSet Line -> Line -> Bool | closesAnySquare :: HS.HashSet Line -> Line -> Bool | ||||||
|  | @ -211,7 +212,7 @@ main = do | ||||||
|   input <- readFile "game.txt" |   input <- readFile "game.txt" | ||||||
|   case parseInput input of |   case parseInput input of | ||||||
|     Nothing -> putStrLn "invalid" |     Nothing -> putStrLn "invalid" | ||||||
|     Just game -> |     Just parsedGame -> | ||||||
|       case scoreGame Player1 game mempty of |       case scoreGame Player1 parsedGame mempty of | ||||||
|         Nothing -> putStrLn "invalid" |         Nothing -> putStrLn "invalid" | ||||||
|         Just score -> print score |         Just score -> print score | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue