git.iko.soy/distributed-process
on master help sign in
Reduce number of required language exts
commit1569533af7b324bf7297e9040f92bc6d56502e56 authorEdsko de Vries <edsko@edsko.net> dateTue 15 May 2012, 13:38 (14 years ago) parent8ce2437
3 files changed+15−11
network-transport-2/network-transport.cabal+7−7 network-transport-2/src/Network/Transport/Internal.hs+5−2 network-transport-2/tests/TestTransport.hs+3−2
network-transport-2/network-transport.cabal+7−7
@@ -19,7 +19,7 @@ Library
1919 Network.Transport.Chan,
2020 Network.Transport.TCP,
2121 Network.Transport.Util
22− extensions: EmptyDataDecls, OverloadedStrings, ForeignFunctionInterface, FlexibleContexts, BangPatterns, ScopedTypeVariables, DeriveDataTypeable
22+ extensions: OverloadedStrings, ForeignFunctionInterface, DeriveDataTypeable
2323 ghc-options: -Wall -fno-warn-unused-do-bind
2424 HS-Source-Dirs: src
2525
@@ -27,14 +27,14 @@ Test-Suite TestTCP
2727 Type: exitcode-stdio-1.0
2828 Main-Is: TestTCP.hs
2929 Build-Depends: base,
30− containers,
3130 bytestring,
31+ containers,
3232 data-accessor,
3333 network,
3434 mtl,
3535 transformers,
3636 ansi-terminal
37− extensions: EmptyDataDecls, OverloadedStrings, ForeignFunctionInterface, FlexibleContexts, BangPatterns, ScopedTypeVariables, DeriveDataTypeable
37+ extensions: OverloadedStrings, ForeignFunctionInterface, FlexibleContexts, DeriveDataTypeable
3838 ghc-options: -Wall -fno-warn-unused-do-bind
3939 HS-Source-Dirs: tests src
4040
@@ -42,13 +42,13 @@ Test-Suite TestMulticastInMemory
4242 Type: exitcode-stdio-1.0
4343 Main-Is: TestMulticastInMemory.hs
4444 Build-Depends: base,
45− containers,
4645 bytestring,
46+ containers,
4747 data-accessor,
4848 mtl,
4949 transformers,
5050 ansi-terminal
51− extensions: EmptyDataDecls, OverloadedStrings, ForeignFunctionInterface, FlexibleContexts, BangPatterns, ScopedTypeVariables, DeriveDataTypeable
51+ extensions: OverloadedStrings, ForeignFunctionInterface, FlexibleContexts, DeriveDataTypeable
5252 ghc-options: -Wall -fno-warn-unused-do-bind
5353 HS-Source-Dirs: tests src
5454
@@ -56,12 +56,12 @@ Test-Suite TestInMemory
5656 Type: exitcode-stdio-1.0
5757 Main-Is: TestInMemory.hs
5858 Build-Depends: base,
59− containers,
6059 bytestring,
60+ containers,
6161 data-accessor,
6262 mtl,
6363 transformers,
6464 ansi-terminal
65− extensions: EmptyDataDecls, OverloadedStrings, ForeignFunctionInterface, FlexibleContexts, BangPatterns, ScopedTypeVariables, DeriveDataTypeable
65+ extensions: OverloadedStrings, ForeignFunctionInterface, FlexibleContexts, DeriveDataTypeable
6666 ghc-options: -Wall -fno-warn-unused-do-bind
6767 HS-Source-Dirs: tests src
network-transport-2/src/Network/Transport/Internal.hs+5−2
@@ -81,5 +81,8 @@ tlog msg = liftIO $ do
8181-}
8282
8383-- | Safe version of 'toEnum'
84−tryToEnum :: forall a. (Enum a, Bounded a) => Int -> Maybe a
85−tryToEnum n = if fromEnum (minBound :: a) <= n && n <= fromEnum (maxBound :: a) then Just (toEnum n) else Nothing
84+tryToEnum :: (Enum a, Bounded a) => Int -> Maybe a
85+tryToEnum = go minBound maxBound
86+ where
87+ go :: Enum b => b -> b -> Int -> Maybe b
88+ go lo hi n = if fromEnum lo <= n && n <= fromEnum hi then Just (toEnum n) else Nothing
network-transport-2/tests/TestTransport.hs+3−2
@@ -268,10 +268,11 @@ testCloseOneDirection transport numPings = do
268268collect :: EndPoint -> Int -> IO [(ConnectionId, [[ByteString]])]
269269collect endPoint numEvents = go numEvents Map.empty Map.empty
270270 where
271− go 0 !open !closed = if Map.null open
271+ -- TODO: for more serious use of this function we'd need to make these arguments strict
272+ go 0 open closed = if Map.null open
272273 then return . Map.toList . Map.map reverse $ closed
273274 else fail "Open connections"
274− go !n !open !closed = do
275+ go n open closed = do
275276 event <- receive endPoint
276277 case event of
277278 ConnectionOpened cid _ _ ->