From: Michael Orlitzky Date: Sun, 5 Jul 2015 06:15:05 +0000 (-0400) Subject: Use explicit imports in IPv4Pattern.hs. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fharbl.git;a=commitdiff_plain;h=a50f9a8628239901278c2c971919132a5747cbd4;ds=sidebyside Use explicit imports in IPv4Pattern.hs. --- diff --git a/src/IPv4Pattern.hs b/src/IPv4Pattern.hs index 5540320..0618453 100644 --- a/src/IPv4Pattern.hs +++ b/src/IPv4Pattern.hs @@ -26,9 +26,19 @@ module IPv4Pattern where + import Test.Tasty ( TestTree, testGroup ) import Test.Tasty.HUnit ( (@?=), testCase ) -import Text.Parsec +import Text.Parsec ( + ParseError, + (<|>), + char, + digit, + many1, + parse, + string, + try, + unexpected ) import Text.Parsec.String ( Parser ) import Text.Read ( readMaybe ) @@ -73,6 +83,8 @@ instance Pretty IPv4Octet where -- -- ==== _Examples_ -- +-- >>> import Text.Parsec ( parseTest ) +-- -- Standard octets are parsed correctly: -- -- >>> parseTest v4octet "0" @@ -108,7 +120,7 @@ v4octet = do -- to convert that to an Int! It will overflow rather than fail -- if the input is too big/small, so it should really always -- succeed. - Nothing -> unexpected "readMaybe failed on a sequence of digits!" + Nothing -> unexpected "v4octet: readMaybe failed on a sequence of digits!" -- If we got an Int, make sure it's actually a representation of -- an octet. @@ -145,6 +157,8 @@ instance Pretty IPv4SequenceMember where -- -- ==== _Examples_ -- +-- >>> import Text.Parsec ( parseTest ) +-- -- >>> parseTest v4seq_member "127" -- IPv4SequenceMemberOctet (IPv4Octet 127) -- @@ -194,6 +208,7 @@ instance Pretty IPv4Sequence where -- -- ==== _Examples_ -- +-- >>> import Text.Parsec ( parseTest ) -- >>> parseTest v4sequence "1" -- IPv4SequenceSingleMember (IPv4SequenceMemberOctet (IPv4Octet 1)) -- @@ -224,7 +239,7 @@ data IPv4Field = IPv4FieldOctet IPv4Octet | IPv4FieldSequence IPv4Sequence instance Pretty IPv4Field where prettyshow (IPv4FieldOctet octet) = prettyshow octet - prettyshow (IPv4FieldSequence seq) = "[" ++ (prettyshow seq) ++ "]" + prettyshow (IPv4FieldSequence s) = "[" ++ (prettyshow s) ++ "]" -- | Parse an IPv4 \"field\", which is either a boring old octet, or a @@ -232,6 +247,7 @@ instance Pretty IPv4Field where -- -- ==== _Examples_ -- +-- >>> import Text.Parsec ( parseTest ) -- >>> parseTest v4field "127" -- IPv4FieldOctet (IPv4Octet 127) -- @@ -287,6 +303,7 @@ instance Pretty IPv4Pattern where -- -- In the module intro, it is mentioned that this is invalid: -- +-- >>> import Text.Parsec ( parseTest ) -- >>> parseTest v4pattern "1.2.[3.4]" -- parse error at (line 1, column 7): -- unexpected "."