]> gitweb.michael.orlitzky.com - dead/harbl.git/blobdiff - src/IPv4Pattern.hs
Use explicit imports in IPv4Pattern.hs.
[dead/harbl.git] / src / IPv4Pattern.hs
index 55403205aa3996914b1b4d9314f68636434ad1c6..06184534c658c724f7421a9345c6ddd5f72d6e4c 100644 (file)
 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 "."