cleaned up error reporting
This commit is contained in:
		
							parent
							
								
									d83589875d
								
							
						
					
					
						commit
						d54a5d514d
					
				
							
								
								
									
										4
									
								
								day2.hs
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								day2.hs
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -32,13 +32,13 @@ validB (Password a' b' t p) =
 | 
			
		|||
    b = (pred b')
 | 
			
		||||
 | 
			
		||||
parse :: String -> Maybe Password
 | 
			
		||||
parse [] = error "empty password"
 | 
			
		||||
parse [] = Nothing
 | 
			
		||||
parse s =
 | 
			
		||||
  do (l,s') <- parseInt s
 | 
			
		||||
     (u,s'') <- parseInt $ dropChar s'
 | 
			
		||||
     (t,s''') <- parseChar $ dropChar s''
 | 
			
		||||
     let p = (dropChar . dropChar) s'''
 | 
			
		||||
      in (Just $ Password l u t p)
 | 
			
		||||
      in Just $ Password l u t p
 | 
			
		||||
 | 
			
		||||
parseInt :: String -> Maybe (Int,String)
 | 
			
		||||
parseInt s = case (reads s) of
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue