File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 1
1
{-# LANGUAGE CPP #-}
2
+ {-# LANGUAGE TypeOperators #-}
2
3
{-# LANGUAGE RecordWildCards #-}
3
4
{-# OPTIONS_GHC -fno-warn-orphans #-}
4
5
@@ -11,6 +12,8 @@ import Data.List.NonEmpty (NonEmpty(..))
11
12
import qualified Data.List.NonEmpty as NE
12
13
import Foreign.Marshal.Alloc (alloca , allocaBytes )
13
14
import Foreign.Marshal.Utils (maybeWith , with )
15
+ import GHC.IsList (IsList (.. ))
16
+ import qualified GHC.IsList as IsList
14
17
import GHC.IO.Exception (IOErrorType (NoSuchThing ))
15
18
import System.IO.Error (ioeSetErrorString , mkIOError )
16
19
@@ -245,6 +248,13 @@ defaultHints = AddrInfo {
245
248
-- >>> addr <- NE.head <$> getAddrInfo (Just hints) (Just "127.0.0.1") (Just "http")
246
249
-- >>> addrAddress addr
247
250
-- 127.0.0.1:80
251
+ getAddrInfo
252
+ :: (Item l ~ AddrInfo , IsList l )
253
+ => Maybe AddrInfo -- ^ preferred socket type or protocol
254
+ -> Maybe HostName -- ^ host name to look up
255
+ -> Maybe ServiceName -- ^ service name to look up
256
+ -> IO l -- ^ resolved addresses, with "best" first
257
+ getAddrInfo hints node service = IsList. fromList . NE. toList <$> getAddrInfoNE hints node service
248
258
249
259
getAddrInfoNE
250
260
:: Maybe AddrInfo -- ^ preferred socket type or protocol
You can’t perform that action at this time.
0 commit comments