Skip to content

Commit

Permalink
Add missing instance
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyRaga committed Aug 14, 2019
1 parent 6066785 commit 6b2f178
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hw-ip.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: hw-ip
version: 2.3.4.0
version: 2.3.4.1
license: BSD-3-Clause
license-file: LICENSE
copyright: 2018-2019 John Ky, David Turnbull, Jian Wan
Expand Down
8 changes: 8 additions & 0 deletions src/HaskellWorks/Data/Network/Ip/Ip.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Data.Word
import GHC.Generics
import HaskellWorks.Data.Bits.BitWise
import HaskellWorks.Data.Network.Ip.Range (Range (..))
import HaskellWorks.Data.Network.Ip.SafeEnum
import HaskellWorks.Data.Network.Ip.Validity
import Text.Read

Expand Down Expand Up @@ -60,6 +61,13 @@ instance Read IpAddress where
Just ip -> [(IpAddressV6 ip, "")]
Nothing -> []

instance SafeEnum IpAddress where
safePred (IpAddressV4 ip) = IpAddressV4 <$> safePred ip
safePred (IpAddressV6 ip) = IpAddressV6 <$> safePred ip

safeSucc (IpAddressV4 ip) = IpAddressV4 <$> safeSucc ip
safeSucc (IpAddressV6 ip) = IpAddressV6 <$> safeSucc ip

isCanonical :: IpBlock v -> Bool
isCanonical (IpBlockV4 b) = V4.isCanonical b
isCanonical (IpBlockV6 b) = V6.isCanonical b
Expand Down

0 comments on commit 6b2f178

Please sign in to comment.