packages feed

ip 1.7.5 → 1.7.6

raw patch · 9 files changed

+72/−29 lines, 9 filesdep ~primitivedep ~textdep ~vector

Dependency ranges changed: primitive, text, vector

Files

ip.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: ip-version: 1.7.5+version: 1.7.6 synopsis: Library for IP and MAC addresses homepage: https://github.com/andrewthad/haskell-ip#readme license: BSD-3-Clause@@ -41,6 +41,7 @@     Net.Types   other-modules:     Data.ByteString.Builder.Fixed+    Data.Text.Builder.Common.Compat     Data.Text.Builder.Common.Internal     Data.Text.Builder.Fixed     Data.Text.Builder.Variable@@ -57,9 +58,9 @@     , natural-arithmetic >= 0.1 && <0.2     , primitive >= 0.6.4 && < 0.8     , bytebuild >= 0.3.4 && <0.4-    , text >= 1.2 && < 1.3+    , text >= 1.2 && < 2.1     , text-short >= 0.1.3 && < 0.2-    , vector >= 0.11 && < 0.13+    , vector >= 0.11 && < 0.14     , wide-word >= 0.1.1.2 && < 0.2     , word-compat >= 0.0.4 && <0.1   ghc-options: -Wall -O2
+ src/Data/Text/Builder/Common/Compat.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE CPP #-}+{- | Compatibility module allowing us to support UTF-16 & UTF-8 versions of+the 'text' package.+-}+module Data.Text.Builder.Common.Compat (Codepoint) where++import Data.Word++#if MIN_VERSION_text(2, 0, 0)+type Codepoint = Word8+#else+type Codepoint = Word16+#endif
src/Data/Text/Builder/Fixed.hs view
@@ -26,9 +26,9 @@ #if !MIN_VERSION_base(4,11,0) import Data.Monoid #endif-import Data.Word import Data.Bits import Data.Char (ord)+import Data.Word import Data.Word.Synthetic.Word12 (Word12) import Data.Text (Text) import qualified Data.Semigroup as Semigroup@@ -83,7 +83,11 @@      in \a ->           let outArr = runST $ do                 marr <- A.new len+#if MIN_VERSION_text(2, 0, 0)+                A.copyI len marr 0 inArr 0+#else                 A.copyI marr 0 inArr 0 len+#endif                 f 0 marr a                 A.unsafeFreeze marr            in TI.text outArr 0 len
src/Data/Text/Builder/Variable.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE MultiWayIf #-}@@ -24,6 +25,7 @@  import Data.Word import Data.Text (Text)+import Data.Text.Builder.Common.Compat (Codepoint) import Control.Monad.ST import Data.Char (ord) import Data.Vector (Vector)@@ -120,15 +122,19 @@         $ \_ marr i -> do           let (arr,len) = fromMaybe xDef (xs Vector.!? i)               finalIx = i + len+#if MIN_VERSION_text(2, 0, 0)+          A.copyI finalIx marr i arr 0+#else           A.copyI marr i arr 0 finalIx+#endif           return finalIx {-# INLINE _vector #-} -i2w :: Integral a => a -> Word16+i2w :: Integral a => a -> Codepoint i2w v = asciiZero + fromIntegral v {-# INLINE i2w #-} -asciiZero :: Word16+asciiZero :: Codepoint asciiZero = 48 {-# INLINE asciiZero #-} 
src/Net/IP.hs view
@@ -1,7 +1,9 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}  {-# OPTIONS_GHC -Wall #-} @@ -60,6 +62,7 @@ import Data.Bits import Data.Coerce (coerce) import Data.Data (Data)+import Data.Hashable (Hashable) import Data.Ix (Ix) import Data.Text (Text) import Data.WideWord (Word128(..))@@ -236,7 +239,8 @@ --   of this type. All functions and typeclass methods that convert --   'IP' values to text will display it as an 'IPv4' address if possible. newtype IP = IP { getIP :: IPv6 }-  deriving (Eq,Ord,Generic,Ix,Data)+  deriving stock (Eq,Ord,Generic,Ix,Data)+  deriving newtype (Hashable)  instance NFData IP 
src/Net/IPv4.hs view
@@ -110,6 +110,7 @@ import Data.Ix (Ix) import Data.Primitive.Types (Prim) import Data.Text (Text)+import Data.Text.Builder.Common.Compat (Codepoint) import Data.Text.Encoding (decodeUtf8') import Data.Text.Internal (Text(..)) import Data.Text.Short (ShortText)@@ -939,10 +940,10 @@ threeDigits = foldMap (BC8.pack . printf "%03d") $ enumFromTo (0 :: Int) 999 {-# NOINLINE threeDigits #-} -i2w :: Integral a => a -> Word16+i2w :: Integral a => a -> Codepoint i2w v = zero + fromIntegral v -zero :: Word16+zero :: Codepoint zero = 48  putAndCount :: Int -> Word -> TArray.MArray s -> ST s Int
src/Net/IPv6.hs view
@@ -76,6 +76,7 @@ import Data.Char (chr) import Data.Data (Data) import Data.Ix (Ix)+import Data.Hashable (Hashable,hashWithSalt) import Data.List (intercalate, group) import Data.Primitive (MutablePrimArray) import Data.Primitive.Types (Prim)@@ -126,6 +127,9 @@ -- | A 128-bit Internet Protocol version 6 address. newtype IPv6 = IPv6 { getIPv6 :: Word128 }   deriving (Bounded,Enum,Eq,Ord,Storable,Bits,FiniteBits,NFData,Prim,Ix,Data,Generic)++instance Hashable IPv6 where+  hashWithSalt s (IPv6 (Word128 a b)) = hashWithSalt (hashWithSalt s a) b  instance Show IPv6 where   showsPrec p addr = showParen (p > 10)
src/Net/Mac.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE LambdaCase #-}@@ -111,7 +112,8 @@ --   type. It is not considered part of the stable API, and it --   allows you to construct invalid MAC addresses. newtype Mac = Mac Word64-  deriving (Eq,Ord,Generic,Ix,Data)+  deriving stock (Eq,Ord,Generic,Ix,Data)+  deriving newtype (Hashable)  instance NFData Mac @@ -868,8 +870,6 @@   | MacGroupingQuadruples !Char -- ^ Four-character groups, @A220.0745.CAC7@   | MacGroupingNoSeparator -- ^ No separator, @24AF4B5B0780@   deriving (Eq,Ord,Show,Read,Generic,Data)--instance Hashable Mac  instance ToJSON Mac where   toJSON = Aeson.String . encode
test/IPv4Text1.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module IPv4Text1 where  import Net.Types (IPv4(..))@@ -63,37 +64,46 @@   get2 = fromIntegral . ByteString.unsafeIndex twoDigits   get3 = fromIntegral . ByteString.unsafeIndex threeDigits -zero,dot :: Word16+-- From Common.Compat, but we don't want to expose the module so we also+-- define 'Codepoint' here.+#if MIN_VERSION_text(2, 0, 0)+type Codepoint = Word8+#else+type Codepoint = Word16+#endif++zero,dot :: Codepoint zero = 48 {-# INLINE zero #-} dot = 46 {-# INLINE dot #-} -i2w :: (Integral a) => a -> Word16+i2w :: (Integral a) => a -> Codepoint i2w v = zero + fromIntegral v {-# INLINE i2w #-} +-- Note: these double backslashes are need here because CPP is enabled. twoDigits :: ByteString twoDigits = BC8.pack-  "0001020304050607080910111213141516171819\-  \2021222324252627282930313233343536373839\-  \4041424344454647484950515253545556575859\-  \6061626364656667686970717273747576777879\+  "0001020304050607080910111213141516171819\\+  \2021222324252627282930313233343536373839\\+  \4041424344454647484950515253545556575859\\+  \6061626364656667686970717273747576777879\\   \8081828384858687888990919293949596979899"  threeDigits :: ByteString threeDigits =   ByteString.replicate 300 0 <> BC8.pack-  "100101102103104105106107108109110111112\-  \113114115116117118119120121122123124125\-  \126127128129130131132133134135136137138\-  \139140141142143144145146147148149150151\-  \152153154155156157158159160161162163164\-  \165166167168169170171172173174175176177\-  \178179180181182183184185186187188189190\-  \191192193194195196197198199200201202203\-  \204205206207208209210211212213214215216\-  \217218219220221222223224225226227228229\-  \230231232233234235236237238239240241242\+  "100101102103104105106107108109110111112\\+  \113114115116117118119120121122123124125\\+  \126127128129130131132133134135136137138\\+  \139140141142143144145146147148149150151\\+  \152153154155156157158159160161162163164\\+  \165166167168169170171172173174175176177\\+  \178179180181182183184185186187188189190\\+  \191192193194195196197198199200201202203\\+  \204205206207208209210211212213214215216\\+  \217218219220221222223224225226227228229\\+  \230231232233234235236237238239240241242\\   \243244245246247248249250251252253254255"