packages feed

ip 0.9.2 → 0.9.3

raw patch · 3 files changed

+18/−15 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Net.Types: instance Foreign.Storable.Storable Net.Types.IPv4

Files

ip.cabal view
@@ -1,5 +1,5 @@ name:                ip-version:             0.9.2+version:             0.9.3 synopsis:            Library for IP and MAC addresses homepage:            https://github.com/andrewthad/haskell-ip#readme license:             BSD3@@ -63,11 +63,11 @@   build-depends:       base        >= 4.8  && < 5     , attoparsec-    , aeson       >= 0.9  && < 1.1+    , aeson       >= 0.9  && < 1.3     , hashable    >= 1.2  && < 1.3     , text        >= 1.2  && < 1.3     , bytestring  >= 0.10 && < 0.11-    , vector      >= 0.11 && < 0.12+    , vector      >= 0.11 && < 0.13     , primitive   -- if impl(ghcjs)   --   build-depends: ghcjs-base >= 0.2 && < 0.3
src/Net/Types.hs view
@@ -32,6 +32,7 @@ import qualified Data.Vector.Primitive.Mutable  as MPVector import qualified Data.Text.Encoding as TE import qualified Data.ByteString.Builder as BB+import Foreign.Storable (Storable(..)) import Data.Word.Synthetic (Word48) import Data.Primitive.Types (Prim) import Data.Bits (Bits,FiniteBits,(.|.),unsafeShiftL)@@ -42,6 +43,7 @@ import Data.Hashable import Data.Aeson (FromJSON(..),ToJSON(..)) import GHC.Generics (Generic)+import Data.Monoid  #if MIN_VERSION_aeson(1,0,0)  import qualified Data.Aeson.Encoding as Aeson@@ -51,7 +53,7 @@  -- | A 32-bit Internet Protocol version 4 address. newtype IPv4 = IPv4 { getIPv4 :: Word32 }-  deriving (Eq,Ord,Show,Read,Enum,Bounded,Hashable,Generic,Prim,Bits,FiniteBits)+  deriving (Eq,Ord,Show,Read,Enum,Bounded,Hashable,Generic,Prim,Bits,FiniteBits,Storable)  -- | A 128-bit Internet Protocol version 6 address. data IPv6 = IPv6@@ -108,7 +110,8 @@ instance ToJSONKey Mac where   toJSONKey = ToJSONKeyText     (\(Mac w) -> Internal.macToTextDefault w)-    (\(Mac w) -> Aeson.unsafeToEncoding $ BB.byteString $ TE.encodeUtf8 $ Internal.macToTextDefault w)+    -- The bytestring encoding currently goes through text. This is suboptimal.+    (\(Mac w) -> Aeson.unsafeToEncoding $ BB.char7 '"' <> BB.byteString (TE.encodeUtf8 $ Internal.macToTextDefault w) <> BB.char7 '"')  instance FromJSONKey Mac where   fromJSONKey = FromJSONKeyTextParser $ \t -> @@ -119,7 +122,7 @@ instance ToJSONKey IPv4 where   toJSONKey = ToJSONKeyText     (\(IPv4 w) -> Internal.toDotDecimalText w)-    (\(IPv4 w) -> Aeson.unsafeToEncoding $ BB.byteString $ TE.encodeUtf8 $ Internal.toDotDecimalText w)+    (\(IPv4 w) -> Aeson.unsafeToEncoding $ BB.char7 '"' <> (BB.byteString $ TE.encodeUtf8 $ Internal.toDotDecimalText w) <> BB.char7 '"')  instance FromJSONKey IPv4 where   fromJSONKey = FromJSONKeyTextParser
test/Test.hs view
@@ -5,12 +5,12 @@ import Test.QuickCheck                      (Gen, Arbitrary(..), choose) import Test.Framework                       (defaultMain, testGroup, Test) import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.Framework.Providers.HUnit       (testCase) import Test.HUnit                           (Assertion,(@?=)) import Numeric                              (showHex) import Test.QuickCheck.Property             (failed,succeeded,Result(..)) import Data.Word import Data.Bifunctor+import qualified Test.Framework.Providers.HUnit as PH  import Net.Types (IPv4(..),IPv4Range(..),Mac(..),IPv6(..)) import qualified Data.Text as Text@@ -44,17 +44,17 @@     [ testGroup "Currently used IPv4 encode/decode" $       [ testProperty "Isomorphism"           $ propEncodeDecodeIso IPv4Text.encode IPv4Text.decode-      , testCase "Decode an IP" testIPv4Decode+      , PH.testCase "Decode an IP" testIPv4Decode       ] ++ testDecodeFailures     , testGroup "Currently used MAC Text encode/decode"       [ testProperty "Isomorphism"           $ propEncodeDecodeIsoSettings MacText.encodeWith MacText.decodeWith-      , testCase "Encode a MAC Address" testMacEncode+      , PH.testCase "Encode a MAC Address" testMacEncode       ]     , testGroup "Currently used MAC ByteString encode/decode"       [ testProperty "Isomorphism"           $ propEncodeDecodeIsoSettings MacByteString.encodeWith MacByteString.decodeWith-      , testCase "Lenient Decoding" testLenientMacByteStringParser+      , PH.testCase "Lenient Decoding" testLenientMacByteStringParser       ]     , testGroup "Naive IPv4 encode/decode"       [ testProperty "Isomorphism"@@ -81,12 +81,12 @@           $ propMatching IPv4ByteString.encode Naive.encodeByteString       ]     , testGroup "IPv4 encode/decode"-      [ testCase "Parser Test Cases" testIPv4Parser+      [ PH.testCase "Parser Test Cases" testIPv4Parser       ]     , testGroup "IPv6 encode/decode"-      [ testCase "Parser Test Cases" testIPv6Parser-      , testCase "Encode test cases" testIPv6Encode-      , testCase "Parser Failure Test Cases" testIPv6ParserFailure+      [ PH.testCase "Parser Test Cases" testIPv6Parser+      , PH.testCase "Encode test cases" testIPv6Encode+      , PH.testCase "Parser Failure Test Cases" testIPv6ParserFailure       ]     ]   , testGroup "IP Range Operations"@@ -252,7 +252,7 @@  testDecodeFailures :: [Test] testDecodeFailures = flip map textBadIPv4 $ \str ->-  testCase ("Should fail to decode [" ++ str ++ "]") $ IPv4Text.decode (Text.pack str) @?= Nothing+  PH.testCase ("Should fail to decode [" ++ str ++ "]") $ IPv4Text.decode (Text.pack str) @?= Nothing  testMacEncode :: Assertion testMacEncode = MacText.encode (Mac.fromOctets 0xFF 0x00 0xAB 0x12 0x99 0x0F)