cleaned up error reporting

This commit is contained in:
Thorn Avery 2020-12-02 21:03:57 +13:00
parent d83589875d
commit d54a5d514d

View File

@ -32,13 +32,13 @@ validB (Password a' b' t p) =
b = (pred b') b = (pred b')
parse :: String -> Maybe Password parse :: String -> Maybe Password
parse [] = error "empty password" parse [] = Nothing
parse s = parse s =
do (l,s') <- parseInt s do (l,s') <- parseInt s
(u,s'') <- parseInt $ dropChar s' (u,s'') <- parseInt $ dropChar s'
(t,s''') <- parseChar $ dropChar s'' (t,s''') <- parseChar $ dropChar s''
let p = (dropChar . 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 :: String -> Maybe (Int,String)
parseInt s = case (reads s) of parseInt s = case (reads s) of