packages feed

hw-ip 2.4.2.0 → 2.4.2.1

raw patch · 16 files changed

+88/−72 lines, 16 filesdep ~bytestringdep ~containersdep ~doctestPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: bytestring, containers, doctest, hedgehog, hspec, optparse-applicative, text

API changes (from Hackage documentation)

Files

app/App/Commands.hs view
@@ -4,6 +4,8 @@ import App.Commands.TextToWord import Options.Applicative +{- HLINT ignore "Monoid law, left identity" -}+ commands :: Parser (IO ()) commands = commandsGeneral 
app/App/Commands/RangeStats.hs view
@@ -15,8 +15,8 @@ import qualified HaskellWorks.Data.Network.Ip.Range as R import qualified Text.Appar.String                  as AP -{-# ANN module ("HLint: ignore Reduce duplication"  :: String) #-}-{-# ANN module ("HLint: ignore Redundant do"        :: String) #-}+{- HLINT ignore "Redundant do"        -}+{- HLINT ignore "Reduce duplication"  -}  runRangeStats :: Z.RangeStatsOptions -> IO () runRangeStats opts =
app/App/Commands/TextToWord.hs view
@@ -8,7 +8,7 @@  import Control.Lens import Data.Generics.Product.Any-import Data.Maybe                (catMaybes)+import Data.Maybe                (mapMaybe) import Options.Applicative       hiding (columns) import Text.Read @@ -18,14 +18,14 @@ import qualified HaskellWorks.Data.Network.Ip.Ipv4 as IPv4 import qualified System.IO                         as IO -{-# ANN module ("HLint: ignore Reduce duplication"  :: String) #-}-{-# ANN module ("HLint: ignore Redundant do"        :: String) #-}+{- HLINT ignore "Redundant do"        -}+{- HLINT ignore "Reduce duplication"  -}  runTextToWord :: Z.TextToWordOptions -> IO () runTextToWord opts = do   contents <- IO.readFile (opts ^. the @"input")   let as  = lines contents-  let ips = catMaybes (fmap (readMaybe @IPv4.IpAddress) as)+  let ips = mapMaybe (readMaybe @IPv4.IpAddress) as   let ws  = fmap (^. the @"word") ips   LBS.writeFile (opts ^. the @"output") (B.toLazyByteString (foldMap B.putWord32le ws)) 
app/App/Commands/Types.hs view
@@ -16,6 +16,6 @@   , output :: FilePath   } deriving (Eq, Show, Generic) -data RangeStatsOptions = RangeStatsOptions+newtype RangeStatsOptions = RangeStatsOptions   { range  :: R.Range IPv4.IpAddress   } deriving (Eq, Show, Generic)
hw-ip.cabal view
@@ -1,10 +1,10 @@ cabal-version: 2.4  name:                   hw-ip-version:                2.4.2.0+version:                2.4.2.1 license:                BSD-3-Clause license-file:           LICENSE-copyright:              2018-2020 John Ky+copyright:              2018-2022 John Ky                         2019-2020 David Turnbull                         2019-2020 Jian Wan maintainer:             newhoggy@gmail.com@@ -14,7 +14,7 @@ synopsis:               Library for manipulating IP addresses and CIDR blocks description:            Library for manipulating IP addresses and CIDR blocks. Please see README.md category:               Network-tested-with:            GHC == 8.10.1, GHC == 8.8.3, GHC == 8.6.5, GHC == 8.4.4+tested-with:            GHC == 9.2.2, GHC == 9.0.2, GHC == 8.10.7, GHC == 8.8.4, GHC == 8.6.5 build-type:             Simple extra-source-files:     README.md @@ -26,19 +26,19 @@  common appar                      { build-depends: appar                      >= 0.1.8      && < 0.2    } common binary                     { build-depends: binary                     >= 0.8        && < 0.9    }-common bytestring                 { build-depends: bytestring                 >= 0.10.6     && < 0.11   }+common bytestring                 { build-depends: bytestring                 >= 0.10.6     && < 0.12   } common containers                 { build-depends: containers                 >= 0.5        && < 0.7    }-common doctest                    { build-depends: doctest                    >= 0.16.2     && < 0.17   }+common doctest                    { build-depends: doctest                    >= 0.16.2     && < 0.21   } common doctest-discover           { build-depends: doctest-discover           >= 0.2        && < 0.3    }-common generic-lens               { build-depends: generic-lens               >= 1.1.0.0    && < 2.1    }-common hedgehog                   { build-depends: hedgehog                   >= 0.6        && < 1.1    }-common hspec                      { build-depends: hspec                      >= 2.4.4      && < 2.8    }+common generic-lens               { build-depends: generic-lens               >= 2.2        && < 2.3    }+common hedgehog                   { build-depends: hedgehog                   >= 0.6        && < 1.2    }+common hspec                      { build-depends: hspec                      >= 2.4.4      && < 3      } common hw-bits                    { build-depends: hw-bits                    >= 0.7        && < 0.8    } common hw-hspec-hedgehog          { build-depends: hw-hspec-hedgehog          >= 0.1.0.2    && < 0.2    } common iproute                    { build-depends: iproute                    >= 1.7.3      && < 1.8    }-common lens                       { build-depends: lens                       >= 4          && < 5      }-common optparse-applicative       { build-depends: optparse-applicative       >= 0.14       && < 0.16   }-common text                       { build-depends: text                       >= 1.2.3.1    && < 1.3    }+common lens                       { build-depends: lens                       >= 4          && < 6      }+common optparse-applicative       { build-depends: optparse-applicative       >= 0.14       && < 0.18   }+common text                       { build-depends: text                       >= 1.2.3.1    && < 3      }  common config   default-language:     Haskell2010@@ -58,8 +58,7 @@                       , hw-bits                       , iproute                       , text-  exposed-modules:      HaskellWorks.Data.Network.Ip-                        HaskellWorks.Data.Network.Ip.Internal.Appar+  exposed-modules:      HaskellWorks.Data.Network.Ip.Internal.Appar                         HaskellWorks.Data.Network.Ip.Ip                         HaskellWorks.Data.Network.Ip.Ipv4                         HaskellWorks.Data.Network.Ip.Ipv6@@ -107,17 +106,23 @@                       , hw-bits                       , hw-hspec-hedgehog                       , hw-ip-                      , hw-ip-gen                       , text   other-modules:        HaskellWorks.Data.Network.IpBlockSpec                         HaskellWorks.Data.Network.IpSpec                         HaskellWorks.Data.Network.Ipv4Spec                         HaskellWorks.Data.Network.Ipv6Spec                         HaskellWorks.Data.Network.RangeSpec+                        HaskellWorks.Data.Network.Unsafe                         HaskellWorks.Data.Network.Word128Spec++                        -- Because stack can't generate haddock otherwise+                        HaskellWorks.Data.Network.Gen+   type:                 exitcode-stdio-1.0   main-is:              Spec.hs   hs-source-dirs:       test+                        -- Because stack can't generate haddock otherwise+                      , gen   ghc-options:          -threaded -rtsopts -with-rtsopts=-N   build-tool-depends:   hspec-discover:hspec-discover @@ -128,7 +133,7 @@                       , hw-ip   default-language:     Haskell2010   type:                 exitcode-stdio-1.0-  ghc-options:          -threaded+  ghc-options:          -threaded -rtsopts -with-rtsopts=-N   main-is:              DoctestDriver.hs   HS-Source-Dirs:       doctest   build-tool-depends:   doctest-discover:doctest-discover
− src/HaskellWorks/Data/Network/Ip.hs
@@ -1,1 +0,0 @@-module HaskellWorks.Data.Network.Ip where
src/HaskellWorks/Data/Network/Ip/Ip.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE DeriveGeneric         #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleInstances     #-}-{-# LANGUAGE InstanceSigs          #-} {-# LANGUAGE OverloadedStrings     #-}  module HaskellWorks.Data.Network.Ip.Ip@@ -27,6 +26,8 @@  import qualified HaskellWorks.Data.Network.Ip.Ipv4 as V4 import qualified HaskellWorks.Data.Network.Ip.Ipv6 as V6++{- HLINT ignore "Use head" -}  data IpBlock v = IpBlockV4 (V4.IpBlock v) | IpBlockV6 (V6.IpBlock v)   deriving (Eq, Ord, Generic)
src/HaskellWorks/Data/Network/Ip/SafeEnum.hs view
@@ -1,5 +1,4 @@-{-# LANGUAGE FlexibleInstances    #-}-{-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE FlexibleInstances #-}  module HaskellWorks.Data.Network.Ip.SafeEnum   ( SafeEnum(..)
src/HaskellWorks/Data/Network/Ip/Word128.hs view
@@ -1,8 +1,6 @@ {-# LANGUAGE DataKinds             #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleInstances     #-}-{-# LANGUAGE InstanceSigs          #-}-{-# LANGUAGE TypeSynonymInstances  #-} {-# OPTIONS_GHC -fno-warn-orphans #-}  module HaskellWorks.Data.Network.Ip.Word128 where@@ -44,9 +42,9 @@                                 in a' B..|. b' B..|. c' B..|. d' :: Integer  instance Num Word128 where-  (+) l r     = integerToWord128 $ (word128ToInteger l) + (word128ToInteger r)-  (-) l r     = integerToWord128 $ (word128ToInteger l) - (word128ToInteger r)-  (*) l r     = integerToWord128 $ (word128ToInteger l) * (word128ToInteger r)+  (+) l r     = integerToWord128 $ word128ToInteger l + word128ToInteger r+  (-) l r     = integerToWord128 $ word128ToInteger l - word128ToInteger r+  (*) l r     = integerToWord128 $ word128ToInteger l * word128ToInteger r   abs a       = a   signum (0, 0, 0, 0) = minBound   signum _            = 1
test/HaskellWorks/Data/Network/IpBlockSpec.hs view
@@ -4,6 +4,7 @@ module HaskellWorks.Data.Network.IpBlockSpec (spec) where  import HaskellWorks.Data.Network.Ip.Validity+import HaskellWorks.Data.Network.Unsafe import HaskellWorks.Hspec.Hedgehog import Hedgehog import Test.Hspec@@ -11,13 +12,13 @@ import qualified HaskellWorks.Data.Network.Ip.Ip   as V import qualified HaskellWorks.Data.Network.Ip.Ipv6 as V6 -{-# ANN module ("HLint: ignore Redundant do"  :: String) #-}+{- HLINT ignore "Redundant do"        -}  spec :: Spec spec = describe "HaskellWorks.Data.Network.IpSpec" $ do   describe "IpBlock" $ do     it "should implement show" $ requireTest $ do-      show (V.IpBlockV6 @Unaligned (V6.IpBlock (V6.IpAddress (3, 3, 3, 0)) (V6.IpNetMask 96))) === "0:3:0:3:0:3::/96"+      unsafeShow (V.IpBlockV6 @Unaligned (V6.IpBlock (V6.IpAddress (3, 3, 3, 0)) (V6.IpNetMask 96))) === "0:3:0:3:0:3::/96"      it "should implement read" $ requireTest $ do       read "1:2:3:4::/127"  === V.IpBlockV6 @Unaligned (V6.IpBlock (V6.IpAddress (0x10002    , 0x30004 , 0, 0)) (V6.IpNetMask 127))
test/HaskellWorks/Data/Network/IpSpec.hs view
@@ -2,32 +2,33 @@ where  import HaskellWorks.Data.Network.Ip.Ip+import HaskellWorks.Data.Network.Unsafe import HaskellWorks.Hspec.Hedgehog import Hedgehog-import Hedgehog.Gen                    as Gen-import Hedgehog.Range                  as Range import Test.Hspec  import qualified HaskellWorks.Data.Network.Ip.Ipv4 as V4 import qualified HaskellWorks.Data.Network.Ip.Ipv6 as V6+import qualified Hedgehog.Gen                      as G+import qualified Hedgehog.Range                    as R -{-# ANN module ("HLint: ignore Redundant do"  :: String) #-}+{- HLINT ignore "Redundant do"        -}  spec :: Spec spec = describe "HaskellWorks.Data.Network.IpSpec" $ do   describe "IpAddress" $ do     it "Should show and read ip v6" $ require $ property $ do-      a <- forAll $ Gen.word32 Range.constantBounded-      b <- forAll $ Gen.word32 Range.constantBounded-      c <- forAll $ Gen.word32 Range.constantBounded-      d <- forAll $ Gen.word32 Range.constantBounded+      a <- forAll $ G.word32 R.constantBounded+      b <- forAll $ G.word32 R.constantBounded+      c <- forAll $ G.word32 R.constantBounded+      d <- forAll $ G.word32 R.constantBounded        let addr = IpAddressV6 (V6.IpAddress (a, b, c, d))-      read (show addr) === addr+      read (unsafeShow addr) === addr    describe "IpAddress" $ do     it "Should show and read ip v4" $ require $ property $ do-      a <- forAll $ Gen.word32 Range.constantBounded+      a <- forAll $ G.word32 R.constantBounded        let addr = IpAddressV4 (V4.IpAddress a)-      read (show addr) === addr+      read (unsafeShow addr) === addr
test/HaskellWorks/Data/Network/Ipv4Spec.hs view
@@ -6,6 +6,7 @@ import HaskellWorks.Data.Network.Ip.Internal.Appar import HaskellWorks.Data.Network.Ip.Ipv4 import HaskellWorks.Data.Network.Ip.Range+import HaskellWorks.Data.Network.Unsafe import HaskellWorks.Hspec.Hedgehog import Hedgehog import Test.Hspec@@ -19,21 +20,21 @@ import qualified Hedgehog.Range                              as R import qualified Text.Appar.String                           as AP -{-# ANN module ("HLint: ignore Redundant do"  :: String) #-}+{- HLINT ignore "Redundant do"        -}  spec :: Spec spec = describe "HaskellWorks.Data.Network.Ipv4Spec" $ do   describe "octet" $ do     it "should go from 0-255" $ require $ property $ do       b <- forAll $ G.word8 R.constantBounded-      AP.runParser octet (show b) === (Just b, "")+      AP.runParser octet (unsafeShow b) === (Just b, "")    describe "I.IpAddress" $ do     it "should implement show" $ requireTest $ do-      show (I.IpAddress 0x000000ff) === "0.0.0.255"-      show (I.IpAddress 0x0000ff00) === "0.0.255.0"-      show (I.IpAddress 0x00ff0000) === "0.255.0.0"-      show (I.IpAddress 0xff000000) === "255.0.0.0"+      unsafeShow (I.IpAddress 0x000000ff) === "0.0.0.255"+      unsafeShow (I.IpAddress 0x0000ff00) === "0.0.255.0"+      unsafeShow (I.IpAddress 0x00ff0000) === "0.255.0.0"+      unsafeShow (I.IpAddress 0xff000000) === "255.0.0.0"      it "should implement read" $ requireTest $ do       read "1.2.3.4"      === I.IpAddress 0x01020304@@ -46,24 +47,24 @@    describe "I.IpBlock" $ do     it "should implement show" $ requireTest $ do-      show (I.IpBlock (I.IpAddress 0x000000ff) (I.IpNetMask 32)) === "0.0.0.255/32"-      show (I.IpBlock (I.IpAddress 0x0000ff00) (I.IpNetMask 32)) === "0.0.255.0/32"-      show (I.IpBlock (I.IpAddress 0x00ff0000) (I.IpNetMask 32)) === "0.255.0.0/32"-      show (I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 32)) === "255.0.0.0/32"-      show (I.IpBlock (I.IpAddress 0x000000ff) (I.IpNetMask 16)) === "0.0.0.255/16"-      show (I.IpBlock (I.IpAddress 0x0000ff00) (I.IpNetMask 16)) === "0.0.255.0/16"-      show (I.IpBlock (I.IpAddress 0x00ff0000) (I.IpNetMask 16)) === "0.255.0.0/16"-      show (I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 16)) === "255.0.0.0/16"-      show (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 8))  === "255.0.0.0"-      show (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 8))  === "255.255.255.255"-      show (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 16)) === "255.0.0.0"-      show (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 16)) === "255.0.255.255"-      show (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 24)) === "255.0.0.0"-      show (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 24)) === "255.0.0.255"-      show (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 32)) === "255.0.0.0"-      show (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 32)) === "255.0.0.0"-      show (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 21)) === "255.0.0.0"-      show (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 21)) === "255.0.7.255"+      unsafeShow (I.IpBlock (I.IpAddress 0x000000ff) (I.IpNetMask 32)) === "0.0.0.255/32"+      unsafeShow (I.IpBlock (I.IpAddress 0x0000ff00) (I.IpNetMask 32)) === "0.0.255.0/32"+      unsafeShow (I.IpBlock (I.IpAddress 0x00ff0000) (I.IpNetMask 32)) === "0.255.0.0/32"+      unsafeShow (I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 32)) === "255.0.0.0/32"+      unsafeShow (I.IpBlock (I.IpAddress 0x000000ff) (I.IpNetMask 16)) === "0.0.0.255/16"+      unsafeShow (I.IpBlock (I.IpAddress 0x0000ff00) (I.IpNetMask 16)) === "0.0.255.0/16"+      unsafeShow (I.IpBlock (I.IpAddress 0x00ff0000) (I.IpNetMask 16)) === "0.255.0.0/16"+      unsafeShow (I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 16)) === "255.0.0.0/16"+      unsafeShow (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 8))  === "255.0.0.0"+      unsafeShow (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 8))  === "255.255.255.255"+      unsafeShow (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 16)) === "255.0.0.0"+      unsafeShow (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 16)) === "255.0.255.255"+      unsafeShow (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 24)) === "255.0.0.0"+      unsafeShow (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 24)) === "255.0.0.255"+      unsafeShow (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 32)) === "255.0.0.0"+      unsafeShow (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 32)) === "255.0.0.0"+      unsafeShow (I.firstIpAddress $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 21)) === "255.0.0.0"+      unsafeShow (I.lastIpAddress  $ I.IpBlock (I.IpAddress 0xff000000) (I.IpNetMask 21)) === "255.0.7.255"      it "should implement read" $ requireTest $ do       read "1.0.0.0/8"  === I.IpBlock @Unaligned (I.IpAddress 0x01000000) (I.IpNetMask 8)
test/HaskellWorks/Data/Network/Ipv6Spec.hs view
@@ -5,6 +5,7 @@  import HaskellWorks.Data.Network.Ip.SafeEnum import HaskellWorks.Data.Network.Ip.Validity+import HaskellWorks.Data.Network.Unsafe      (unsafeShow) import HaskellWorks.Hspec.Hedgehog import Hedgehog import Test.Hspec@@ -21,13 +22,13 @@ import qualified Hedgehog.Gen   as G import qualified Hedgehog.Range as R -{-# ANN module ("HLint: ignore Redundant do"  :: String) #-}+{- HLINT ignore "Redundant do"              -}  spec :: Spec spec = describe "HaskellWorks.Data.Network.Ipv6Spec" $ do   describe "V6.IpBlock" $ do     it "should implement show" $ requireTest $ do-      show (V6.IpBlock (V6.IpAddress (3, 3, 3, 0)) (V6.IpNetMask 96)) === "0:3:0:3:0:3::/96"+      unsafeShow (V6.IpBlock (V6.IpAddress (3, 3, 3, 0)) (V6.IpNetMask 96)) === "0:3:0:3:0:3::/96"      it "should implement firstAddress/lastAddress" $ requireTest $ do       V.firstIpAddress (V.IpBlockV4 (V4.IpBlock (V4.IpAddress   0xff000000) (V4.IpNetMask  8)))  === (0, 0, 0xFFFF, 0xFF000000)@@ -48,7 +49,7 @@       a <- forAll $ G.word32 R.constantBounded       m <- forAll $ G.word8 $ R.linear 0 128       let addr = V6.IpBlock (V6.IpAddress (a, 0, 0, 0)) (V6.IpNetMask m)-      V6.parseIpBlock (T.pack (show addr)) === Right addr+      V6.parseIpBlock (T.pack (unsafeShow addr)) === Right addr      it "should support enum" $ require $ property $ do       boundedPred (V6.IpAddress (32, 32, 32, 32)) === V6.IpAddress (32, 32, 32, 31)
test/HaskellWorks/Data/Network/RangeSpec.hs view
@@ -13,7 +13,7 @@ import qualified HaskellWorks.Data.Network.Ip.Range as R import qualified Text.Appar.String                  as AP -{-# ANN module ("HLint: ignore Redundant do"  :: String) #-}+{- HLINT ignore "Redundant do"        -}  spec :: Spec spec = describe "HaskellWorks.Data.Network.RangeSpec" $ do
+ test/HaskellWorks/Data/Network/Unsafe.hs view
@@ -0,0 +1,8 @@+module HaskellWorks.Data.Network.Unsafe+  ( unsafeShow+  ) where++{- HLINT ignore "Avoid restricted function" -}++unsafeShow :: Show a => a -> String+unsafeShow = show
test/HaskellWorks/Data/Network/Word128Spec.hs view
@@ -9,7 +9,7 @@ import qualified Data.Bits                            as B import qualified HaskellWorks.Data.Network.Ip.Word128 as W -{-# ANN module ("HLint: ignore Redundant do"  :: String) #-}+{- HLINT ignore "Redundant do"        -}  spec :: Spec spec = describe "HaskellWorks.Data.Network.Ipv6Spec" $ do