From: Michael Orlitzky Date: Fri, 2 Apr 2010 04:45:13 +0000 (-0400) Subject: Unqualify the Data.List import, and specify the functions that we need. X-Git-Tag: 0.0.1~92 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=acd934f90958d6c767fa8140c1a0702e3a6facaf;p=hath.git Unqualify the Data.List import, and specify the functions that we need. --- diff --git a/src/Main.hs b/src/Main.hs index 5336537..13f3ff8 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,5 +1,5 @@ import Data.Char (digitToInt, intToDigit) -import qualified Data.List as DL +import Data.List (concatMap, intercalate, intersperse, splitAt) import qualified Numeric as N import System.Exit (exitFailure) import Text.Regex.Posix @@ -28,7 +28,7 @@ base_two n = N.showIntAtBase 2 intToDigit n "" -- characters, and concatenated together. octets_base_two :: [Int] -> String octets_base_two octet_list = - DL.concatMap ((pad_left_to 8 '0') .base_two) octet_list + concatMap ((pad_left_to 8 '0') .base_two) octet_list -- Returns the minimum address (as a base-two string) satisfying the @@ -55,10 +55,10 @@ min_base_two_octets cidr = [octet1, octet2, octet3, octet4] where addr = min_base_two_address cidr - octet1 = fst (DL.splitAt 8 addr) - octet2 = fst (DL.splitAt 8 (snd (DL.splitAt 8 addr))) - octet3 = fst (DL.splitAt 8 (snd (DL.splitAt 16 addr))) - octet4 = snd (DL.splitAt 24 addr) + octet1 = fst (splitAt 8 addr) + octet2 = fst (splitAt 8 (snd (splitAt 8 addr))) + octet3 = fst (splitAt 8 (snd (splitAt 16 addr))) + octet4 = snd (splitAt 24 addr) -- The octet components of max_base_two_address, as a base-two String. @@ -67,10 +67,10 @@ max_base_two_octets cidr = [octet1, octet2, octet3, octet4] where addr = max_base_two_address cidr - octet1 = fst (DL.splitAt 8 addr) - octet2 = fst (DL.splitAt 8 (snd (DL.splitAt 8 addr))) - octet3 = fst (DL.splitAt 8 (snd (DL.splitAt 16 addr))) - octet4 = snd (DL.splitAt 24 addr) + octet1 = fst (splitAt 8 addr) + octet2 = fst (splitAt 8 (snd (splitAt 8 addr))) + octet3 = fst (splitAt 8 (snd (splitAt 16 addr))) + octet4 = snd (splitAt 24 addr) -- The octet components of min_base_two_address, as Ints. @@ -130,7 +130,7 @@ addr_barrier x = non_addr_char ++ x ++ non_addr_char -- 5. Stick an address boundary on either side of the result. cidr_to_regex :: String -> String cidr_to_regex cidr = - addr_barrier (DL.intercalate "\\." [range1, range2, range3, range4]) + addr_barrier (intercalate "\\." [range1, range2, range3, range4]) where range1 = numeric_range min1 max1 range2 = numeric_range min2 max2 @@ -155,7 +155,7 @@ is_valid_cidr cidr = cidr =~ "([0-9]{1,3}\\.){3}[0-9]{1,3}/[0-9]{1,2}" -- Take a list of Strings, and return a regular expression matching -- any of them. alternate :: [String] -> String -alternate terms = "(" ++ (concat (DL.intersperse "|" terms)) ++ ")" +alternate terms = "(" ++ (concat (intersperse "|" terms)) ++ ")" -- Take two Ints as parameters, and return a regex matching any