]> gitweb.michael.orlitzky.com - hath.git/blobdiff - src/Cidr.hs
Bump the version number to 0.0.4 in hath.cabal.
[hath.git] / src / Cidr.hs
index 7143a809b9975ee1d88844657ee7f5ee03cb011c..e23ae6c1a55a2ba0e9c9de333cc4c8bbbb369453 100644 (file)
@@ -8,6 +8,7 @@ module Cidr
   combine_all,
   contains,
   contains_proper,
+  enumerate,
   max_octet1,
   max_octet2,
   max_octet3,
@@ -22,7 +23,7 @@ module Cidr
 
 import Data.List (nubBy)
 import Data.List.Split (splitOneOf)
-import Data.Maybe (catMaybes, fromJust)
+import Data.Maybe (catMaybes, fromJust, mapMaybe)
 
 import Test.HUnit (assertEqual)
 import Test.Framework (Test, testGroup)
@@ -77,7 +78,7 @@ maskbits_from_cidr_string s
 --   of its octets (as Ints).
 octets_from_cidr_string :: String -> [Octet]
 octets_from_cidr_string s =
-  catMaybes $ map octet_from_string (take 4 (splitOneOf "./" s))
+  mapMaybe octet_from_string (take 4 (splitOneOf "./" s))
 
 
 -- | Return Nothing if we can't parse both maskbits and octets from
@@ -254,7 +255,8 @@ adjacent cidr1 cidr2
     mbits2 = maskbits cidr2
 
 
-
+enumerate :: Cidr -> [IPv4Address]
+enumerate cidr = [(min_host cidr)..(max_host cidr)]
 
 
 -- HUnit Tests