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.
This commit is contained in:
Scott Fleischman 2019-05-30 11:33:13 -07:00
parent 3334d819b4
commit f84cc03517

View file

@ -1,5 +1,5 @@
-- | Compatibility layer for network package, including newtype 'PortID'
{-# LANGUAGE CPP, PackageImports #-}
{-# LANGUAGE CPP, GeneralizedNewtypeDeriving #-}
module Database.MongoDB.Internal.Network (PortID(..), N.HostName, connectTo) where
@ -21,7 +21,7 @@ import System.IO (Handle, IOMode(ReadWriteMode))
-- | Wraps network's 'PortNumber'
-- Used to ease compatibility between older and newer network versions.
newtype PortID = PortNumber N.PortNumber deriving (Show, Eq, Ord)
newtype PortID = PortNumber N.PortNumber deriving (Enum, Eq, Integral, Num, Ord, Read, Real, Show)
#if !MIN_VERSION_network(2, 9, 0)