Skip to content

Commit

Permalink
using unliftio concretely
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Apr 16, 2024
1 parent 8fdefc0 commit 52a9619
Show file tree
Hide file tree
Showing 27 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Network/HPACK/HeaderBlock/Decode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module Network.HPACK.HeaderBlock.Decode (
decodeSimple, -- testing
) where

import Control.Exception (catch, throwIO)
import Data.Array.Base (unsafeRead, unsafeWrite)
import qualified Data.Array.IO as IOA
import qualified Data.Array.Unsafe as Unsafe
Expand All @@ -23,6 +22,7 @@ import qualified Data.ByteString.Char8 as B8
import Data.Char (isUpper)
import Network.ByteOrder
import Network.HTTP.Semantics
import UnliftIO.Exception (catch, throwIO)

import Imports hiding (empty)
import Network.HPACK.Builder
Expand Down
4 changes: 2 additions & 2 deletions Network/HPACK/HeaderBlock/Encode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ module Network.HPACK.HeaderBlock.Encode (
encodeS,
) where

import Control.Exception (bracket, throwIO)
import qualified Control.Exception as E
import qualified Data.ByteString as BS
import Data.ByteString.Internal (create)
import Data.IORef
Expand All @@ -18,6 +16,8 @@ import Foreign.Marshal.Utils (copyBytes)
import Foreign.Ptr (minusPtr)
import Network.ByteOrder
import Network.HTTP.Semantics
import UnliftIO.Exception (bracket, throwIO)
import qualified UnliftIO.Exception as E

import Imports
import Network.HPACK.HeaderBlock.Integer
Expand Down
2 changes: 1 addition & 1 deletion Network/HPACK/Huffman/Decode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module Network.HPACK.Huffman.Decode (
GCBuffer,
) where

import Control.Exception (throwIO)
import Data.Array (Array, listArray)
import Data.Array.Base (unsafeAt)
import qualified Data.ByteString as BS
import Network.ByteOrder
import UnliftIO.Exception (throwIO)

import Imports
import Network.HPACK.Huffman.Bit
Expand Down
2 changes: 1 addition & 1 deletion Network/HPACK/Huffman/Encode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ module Network.HPACK.Huffman.Encode (
encodeHuffman,
) where

import Control.Exception (throwIO)
import Data.Array.Base (unsafeAt)
import Data.Array.IArray (listArray)
import Data.Array.Unboxed (UArray)
import Data.IORef
import Foreign.Ptr (minusPtr, plusPtr)
import Foreign.Storable (poke)
import Network.ByteOrder hiding (copy)
import UnliftIO.Exception (throwIO)

import Imports
import Network.HPACK.Huffman.Params (idxEos)
Expand Down
2 changes: 1 addition & 1 deletion Network/HPACK/Table/Dynamic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ module Network.HPACK.Table.Dynamic (
getRevIndex,
) where

import Control.Exception (throwIO)
import Data.Array.Base (unsafeRead, unsafeWrite)
import Data.Array.IO (IOArray, newArray)
import qualified Data.ByteString.Char8 as BS
import Data.IORef
import UnliftIO.Exception (throwIO)

import Imports
import Network.HPACK.Huffman
Expand Down
3 changes: 1 addition & 2 deletions Network/HPACK/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ module Network.HPACK.Types (
BufferOverrun (..),
) where

import Control.Exception as E
import Data.Typeable
import Network.ByteOrder (Buffer, BufferOverrun (..), BufferSize)
import UnliftIO.Exception as E

import Imports

Expand Down
4 changes: 2 additions & 2 deletions Network/HTTP2/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
-- >
-- > module Main where
-- >
-- > import Control.Concurrent.Async
-- > import qualified Control.Exception as E
-- > import qualified Data.ByteString.Char8 as C8
-- > import Network.HTTP.Types
-- > import Network.Run.TCP (runTCPClient) -- network-run
-- > import UnliftIO.Async -- unliftio
-- > import qualified UnliftIO.Exception as E -- unliftio
-- >
-- > import Network.HTTP2.Client
-- >
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/Client/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Network.HTTP2.Client.Run where

import Control.Concurrent.STM (check)
import Control.Exception
import Data.ByteString.Builder (Builder)
import qualified Data.ByteString.UTF8 as UTF8
import Data.IORef
Expand All @@ -17,6 +16,7 @@ import Network.HTTP.Semantics.IO
import Network.Socket (SockAddr)
import UnliftIO.Async
import UnliftIO.Concurrent
import UnliftIO.Exception
import UnliftIO.STM

import Imports
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/Frame/Decode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ module Network.HTTP2.Frame.Decode (
decodeContinuationFrame,
) where

import Control.Exception (Exception)
import Data.Array (Array, listArray, (!))
import qualified Data.ByteString as BS
import Foreign.Ptr (Ptr, plusPtr)
import qualified Network.ByteOrder as N
import System.IO.Unsafe (unsafeDupablePerformIO)
import UnliftIO.Exception (Exception)

import Imports
import Network.HTTP2.Frame.Types
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/H2/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

module Network.HTTP2.H2.Context where

import Control.Exception
import Data.IORef
import Network.Control
import Network.Socket (SockAddr)
import UnliftIO.Exception
import qualified UnliftIO.Exception as E
import UnliftIO.STM

Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/H2/HPACK.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ module Network.HTTP2.H2.HPACK (
fixHeaders,
) where

import qualified Control.Exception as E
import Network.ByteOrder
import Network.HTTP.Semantics
import Network.HTTP.Types
import qualified UnliftIO.Exception as E

import Imports
import Network.HPACK
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/H2/Manager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ module Network.HTTP2.H2.Manager (
waitCounter0,
) where

import Control.Exception
import Data.Foldable
import Data.IORef
import Data.Set (Set)
import qualified Data.Set as Set
import qualified System.TimeManager as T
import UnliftIO.Concurrent
import UnliftIO.Exception
import qualified UnliftIO.Exception as E
import UnliftIO.STM

Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/H2/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

module Network.HTTP2.H2.Stream where

import Control.Exception
import Control.Monad
import Data.IORef
import Data.Maybe (fromMaybe)
import Network.Control
import UnliftIO.Concurrent
import UnliftIO.Exception
import UnliftIO.STM

import Network.HTTP2.Frame
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/H2/StreamTable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ module Network.HTTP2.H2.StreamTable (

import Control.Concurrent
import Control.Concurrent.STM
import Control.Exception
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import Network.Control (LRUCache)
import qualified Network.Control as LRUCache
import UnliftIO.Exception

import Imports
import Network.HTTP2.H2.Types (Stream (..))
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/H2/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Network.HTTP2.H2.Types where

import qualified Control.Exception as E
import Data.IORef
import Data.Typeable
import Network.Control
Expand All @@ -15,6 +14,7 @@ import System.IO.Unsafe
import qualified System.TimeManager as T
import UnliftIO.Concurrent
import UnliftIO.Exception (SomeException)
import qualified UnliftIO.Exception as E
import UnliftIO.STM

import Imports
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-- > {-# LANGUAGE OverloadedStrings #-}
-- > module Main (main) where
-- >
-- > import qualified Control.Exception as E
-- > import qualified UnliftIO.Exception as E
-- > import Data.ByteString.Builder (byteString)
-- > import Network.HTTP.Types (ok200)
-- > import Network.Run.TCP (runTCPServer) -- network-run
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/Server/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
module Network.HTTP2.Server.Run where

import Control.Concurrent.STM
import Control.Exception
import Imports
import Network.Control (defaultMaxData)
import Network.HTTP.Semantics.Server
import Network.HTTP.Semantics.Server.Internal
import Network.Socket (SockAddr)
import UnliftIO.Async (concurrently_)
import UnliftIO.Exception

import Network.HTTP2.Frame
import Network.HTTP2.H2
Expand Down
2 changes: 1 addition & 1 deletion bench-hpack/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

module Main where

import Control.Exception
import Data.ByteString (ByteString)
import Gauge.Main
import Network.HPACK
import UnliftIO.Exception

----------------------------------------------------------------

Expand Down
9 changes: 7 additions & 2 deletions http2.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ executable h2c-client
bytestring,
http-types,
http2,
network-run
network-run,
unliftio

if flag(devel)

Expand All @@ -159,7 +160,8 @@ executable h2c-server
crypton,
http2,
http-types,
network-run
network-run,
unliftio

if flag(devel)

Expand Down Expand Up @@ -216,6 +218,7 @@ executable hpack-debug
http2,
network-byte-order,
text,
unliftio,
unordered-containers,
vector,
word8
Expand Down Expand Up @@ -309,6 +312,7 @@ test-suite spec
network,
network-run >=0.1.0,
random,
unliftio,
typed-process

test-suite spec2
Expand Down Expand Up @@ -357,6 +361,7 @@ test-suite hpack
hspec >=1.3,
http2,
text,
unliftio,
unordered-containers,
vector

Expand Down
2 changes: 1 addition & 1 deletion test-hpack/HPACKDecode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ module HPACKDecode (
#if __GLASGOW_HASKELL__ < 709
import Control.Applicative ((<$>))
#endif
import Control.Exception
import Control.Monad (when)
import qualified Data.ByteString.Base16 as B16
import qualified Data.ByteString.Char8 as B8
import Data.List (sort)
import Network.HPACK
import Network.HPACK.Table
import UnliftIO.Exception

import JSON

Expand Down
2 changes: 1 addition & 1 deletion test/HPACK/EncodeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module HPACK.EncodeSpec where
#if __GLASGOW_HASKELL__ < 709
import Control.Applicative ((<$>))
#endif
import qualified Control.Exception as E
import Data.Bits
import qualified Data.ByteString as BS
import Data.Maybe (fromMaybe)
import Network.HPACK
import Test.Hspec
import qualified UnliftIO.Exception as E

spec :: Spec
spec = do
Expand Down
2 changes: 1 addition & 1 deletion test/HTTP2/ClientSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module HTTP2.ClientSpec where

import Control.Concurrent
import qualified Control.Exception as E
import Control.Monad
import Data.ByteString.Builder (byteString)
import Data.Foldable (for_)
Expand All @@ -19,6 +18,7 @@ import System.IO.Unsafe (unsafePerformIO)
import System.Random
import System.Timeout (timeout)
import Test.Hspec
import qualified UnliftIO.Exception as E

import Network.HTTP2.Client
import qualified Network.HTTP2.Server as S
Expand Down
4 changes: 2 additions & 2 deletions test/HTTP2/ServerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
module HTTP2.ServerSpec where

import Control.Concurrent
import Control.Concurrent.Async
import qualified Control.Exception as E
import Control.Monad
import Crypto.Hash (Context, SHA1) -- cryptonite
import qualified Crypto.Hash as CH
Expand All @@ -25,6 +23,8 @@ import System.IO
import System.IO.Unsafe
import System.Random
import Test.Hspec
import UnliftIO.Async
import qualified UnliftIO.Exception as E

import Network.HPACK
import Network.HPACK.Internal
Expand Down
2 changes: 1 addition & 1 deletion test2/ServerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
module ServerSpec (spec) where

import Control.Concurrent
import qualified Control.Exception as E
import Data.ByteString.Builder (byteString)
import Network.HTTP.Types
import Network.Run.TCP
import System.Exit
import System.Process.Typed
import Test.Hspec
import qualified UnliftIO.Exception as E

import Network.HTTP2.Server

Expand Down
4 changes: 2 additions & 2 deletions util/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

module Client where

import Control.Concurrent.Async
import qualified Control.Exception as E
import qualified Data.ByteString.Char8 as C8
import Network.HTTP.Types
import UnliftIO.Async
import qualified UnliftIO.Exception as E

import Network.HTTP2.Client

Expand Down
2 changes: 1 addition & 1 deletion util/h2c-client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

module Main where

import qualified Control.Exception as E
import qualified Data.ByteString.Char8 as C8
import Network.HTTP2.Client
import Network.Run.TCP (runTCPClient)
import System.Console.GetOpt
import System.Environment
import System.Exit
import qualified UnliftIO.Exception as E

import Client

Expand Down
Loading

0 comments on commit 52a9619

Please sign in to comment.