Skip to content

Commit 6a014ee

Browse files
committed
defining CustomSockOpt again with ViewPatterns.
Credit: David Feuer <[email protected]>
1 parent 317ab6a commit 6a014ee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Network/Socket/Options.hsc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE DeriveDataTypeable #-}
33
{-# LANGUAGE PatternSynonyms #-}
44
{-# LANGUAGE ScopedTypeVariables #-}
5+
{-# LANGUAGE ViewPatterns #-}
56

67
#include "HsNet.h"
78
##include "HsNetDef.h"
@@ -14,7 +15,8 @@ module Network.Socket.Options (
1415
,RecvLowWater,SendLowWater,RecvTimeOut,SendTimeOut
1516
,UseLoopBack,UserTimeout,IPv6Only
1617
,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo
17-
,RecvIPv6HopLimit,RecvIPv6TClass,RecvIPv6PktInfo)
18+
,RecvIPv6HopLimit,RecvIPv6TClass,RecvIPv6PktInfo
19+
,CustomSockOpt)
1820
, isSupportedSocketOption
1921
, whenSupported
2022
, getSocketType
@@ -273,6 +275,11 @@ pattern RecvIPv6PktInfo = SockOpt (-1) (-1)
273275
#endif
274276
#endif // HAVE_DECL_IPPROTO_IPV6
275277

278+
pattern CustomSockOpt :: (CInt, CInt) -> SocketOption
279+
pattern CustomSockOpt xy <- ((\(SockOpt x y) -> (x, y)) -> xy)
280+
where
281+
CustomSockOpt (x, y) = SockOpt x y
282+
276283
#ifdef SO_LINGER
277284
data StructLinger = StructLinger CInt CInt
278285

0 commit comments

Comments
 (0)