From: Michael Orlitzky Date: Mon, 19 Aug 2013 13:45:00 +0000 (-0400) Subject: Simplify Read instance code. X-Git-Tag: 0.0.4~3 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=cca5aba75c313151878a98344c289827c94151e7;p=hath.git Simplify Read instance code. --- diff --git a/src/Cidr.hs b/src/Cidr.hs index dc2b556..368cf76 100644 --- a/src/Cidr.hs +++ b/src/Cidr.hs @@ -85,7 +85,7 @@ octets_from_cidr_string s = instance Read Cidr where -- | Parse everything or nothing. - readsPrec _ = \s -> + readsPrec _ s = case (octets_from_cidr_string s) of [oct1, oct2, oct3, oct4] -> case (maskbits_from_cidr_string s) of diff --git a/src/Maskbits.hs b/src/Maskbits.hs index 51701f5..5eb7649 100644 --- a/src/Maskbits.hs +++ b/src/Maskbits.hs @@ -118,12 +118,12 @@ instance Arbitrary Maskbits where instance Read Maskbits where - readsPrec _ = \s -> + readsPrec _ s = case (reads s :: [(Int, String)]) of [] -> [] (x,leftover):_ -> go x leftover where go :: Int -> String -> [(Maskbits, String)] - go y s - | y < minBound || y > maxBound = [] - | otherwise = [(toEnum y, s)] + go x' leftover' + | x' < minBound || x' > maxBound = [] + | otherwise = [(toEnum x', leftover')] diff --git a/src/Octet.hs b/src/Octet.hs index c472f8d..6d6c8c8 100644 --- a/src/Octet.hs +++ b/src/Octet.hs @@ -136,15 +136,15 @@ instance Enum Octet where instance Read Octet where - readsPrec _ = \s -> + readsPrec _ s = case (reads s :: [(Int, String)]) of [] -> [] (x,leftover):_ -> go x leftover where go :: Int -> String -> [(Octet, String)] - go y s - | y < minBound || y > maxBound = [] - | otherwise = [(toEnum y, s)] + go x' leftover' + | x' < minBound || x' > maxBound = [] + | otherwise = [(toEnum x', leftover')] -- Test lists.