From f84cc035179198ed63a5e247aa7c95f61ce7a295 Mon Sep 17 00:00:00 2001 From: Scott Fleischman Date: Thu, 30 May 2019 11:33:13 -0700 Subject: [PATCH] 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. --- Database/MongoDB/Internal/Network.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Database/MongoDB/Internal/Network.hs b/Database/MongoDB/Internal/Network.hs index 84362b7..ae94830 100644 --- a/Database/MongoDB/Internal/Network.hs +++ b/Database/MongoDB/Internal/Network.hs @@ -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)