Skip to content

Commit f84cc03

Browse files
Add numeric instances that network's PortNumber has.
In particular this allows you to use `fromIntegral` without having to add the newtype wrapper. This can help existing code move away from importing and referencing the PortID type altogether.
1 parent 3334d81 commit f84cc03

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Database/MongoDB/Internal/Network.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- | Compatibility layer for network package, including newtype 'PortID'
2-
{-# LANGUAGE CPP, PackageImports #-}
2+
{-# LANGUAGE CPP, GeneralizedNewtypeDeriving #-}
33

44
module Database.MongoDB.Internal.Network (PortID(..), N.HostName, connectTo) where
55

@@ -21,7 +21,7 @@ import System.IO (Handle, IOMode(ReadWriteMode))
2121

2222
-- | Wraps network's 'PortNumber'
2323
-- Used to ease compatibility between older and newer network versions.
24-
newtype PortID = PortNumber N.PortNumber deriving (Show, Eq, Ord)
24+
newtype PortID = PortNumber N.PortNumber deriving (Enum, Eq, Integral, Num, Ord, Read, Real, Show)
2525

2626

2727
#if !MIN_VERSION_network(2, 9, 0)

0 commit comments

Comments
 (0)