{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}

module Network.HTTP2.Frame.Types where

import Data.Ix
import Network.Control (WindowSize)
import Text.Read
import qualified Text.Read.Lex as L

import Imports

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

-- | The length of HTTP/2 frame header.
--
-- >>> frameHeaderLength
-- 9
frameHeaderLength :: Int
frameHeaderLength :: StreamId
frameHeaderLength = StreamId
9

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

-- | The type for raw error code.
newtype ErrorCode = ErrorCode Word32 deriving (ErrorCode -> ErrorCode -> Bool
(ErrorCode -> ErrorCode -> Bool)
-> (ErrorCode -> ErrorCode -> Bool) -> Eq ErrorCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ErrorCode -> ErrorCode -> Bool
== :: ErrorCode -> ErrorCode -> Bool
$c/= :: ErrorCode -> ErrorCode -> Bool
/= :: ErrorCode -> ErrorCode -> Bool
Eq, Eq ErrorCode
Eq ErrorCode =>
(ErrorCode -> ErrorCode -> Ordering)
-> (ErrorCode -> ErrorCode -> Bool)
-> (ErrorCode -> ErrorCode -> Bool)
-> (ErrorCode -> ErrorCode -> Bool)
-> (ErrorCode -> ErrorCode -> Bool)
-> (ErrorCode -> ErrorCode -> ErrorCode)
-> (ErrorCode -> ErrorCode -> ErrorCode)
-> Ord ErrorCode
ErrorCode -> ErrorCode -> Bool
ErrorCode -> ErrorCode -> Ordering
ErrorCode -> ErrorCode -> ErrorCode
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ErrorCode -> ErrorCode -> Ordering
compare :: ErrorCode -> ErrorCode -> Ordering
$c< :: ErrorCode -> ErrorCode -> Bool
< :: ErrorCode -> ErrorCode -> Bool
$c<= :: ErrorCode -> ErrorCode -> Bool
<= :: ErrorCode -> ErrorCode -> Bool
$c> :: ErrorCode -> ErrorCode -> Bool
> :: ErrorCode -> ErrorCode -> Bool
$c>= :: ErrorCode -> ErrorCode -> Bool
>= :: ErrorCode -> ErrorCode -> Bool
$cmax :: ErrorCode -> ErrorCode -> ErrorCode
max :: ErrorCode -> ErrorCode -> ErrorCode
$cmin :: ErrorCode -> ErrorCode -> ErrorCode
min :: ErrorCode -> ErrorCode -> ErrorCode
Ord, ReadPrec [ErrorCode]
ReadPrec ErrorCode
StreamId -> ReadS ErrorCode
ReadS [ErrorCode]
(StreamId -> ReadS ErrorCode)
-> ReadS [ErrorCode]
-> ReadPrec ErrorCode
-> ReadPrec [ErrorCode]
-> Read ErrorCode
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: StreamId -> ReadS ErrorCode
readsPrec :: StreamId -> ReadS ErrorCode
$creadList :: ReadS [ErrorCode]
readList :: ReadS [ErrorCode]
$creadPrec :: ReadPrec ErrorCode
readPrec :: ReadPrec ErrorCode
$creadListPrec :: ReadPrec [ErrorCode]
readListPrec :: ReadPrec [ErrorCode]
Read)

fromErrorCode :: ErrorCode -> Word32
fromErrorCode :: ErrorCode -> Word32
fromErrorCode (ErrorCode Word32
w) = Word32
w

toErrorCode :: Word32 -> ErrorCode
toErrorCode :: Word32 -> ErrorCode
toErrorCode = Word32 -> ErrorCode
ErrorCode

-- | The type for error code. See <https://www.rfc-editor.org/rfc/rfc9113#ErrorCodes>.

{- FOURMOLU_DISABLE -}
pattern NoError            :: ErrorCode
pattern $mNoError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bNoError :: ErrorCode
NoError             = ErrorCode 0x0

pattern ProtocolError      :: ErrorCode
pattern $mProtocolError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bProtocolError :: ErrorCode
ProtocolError       = ErrorCode 0x1

pattern InternalError      :: ErrorCode
pattern $mInternalError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bInternalError :: ErrorCode
InternalError       = ErrorCode 0x2

pattern FlowControlError   :: ErrorCode
pattern $mFlowControlError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bFlowControlError :: ErrorCode
FlowControlError    = ErrorCode 0x3

pattern SettingsTimeout    :: ErrorCode
pattern $mSettingsTimeout :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bSettingsTimeout :: ErrorCode
SettingsTimeout     = ErrorCode 0x4

pattern StreamClosed       :: ErrorCode
pattern $mStreamClosed :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bStreamClosed :: ErrorCode
StreamClosed        = ErrorCode 0x5

pattern FrameSizeError     :: ErrorCode
pattern $mFrameSizeError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bFrameSizeError :: ErrorCode
FrameSizeError      = ErrorCode 0x6

pattern RefusedStream      :: ErrorCode
pattern $mRefusedStream :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bRefusedStream :: ErrorCode
RefusedStream       = ErrorCode 0x7

pattern Cancel             :: ErrorCode
pattern $mCancel :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bCancel :: ErrorCode
Cancel              = ErrorCode 0x8

pattern CompressionError   :: ErrorCode
pattern $mCompressionError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bCompressionError :: ErrorCode
CompressionError    = ErrorCode 0x9

pattern ConnectError       :: ErrorCode
pattern $mConnectError :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bConnectError :: ErrorCode
ConnectError        = ErrorCode 0xa

pattern EnhanceYourCalm    :: ErrorCode
pattern $mEnhanceYourCalm :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bEnhanceYourCalm :: ErrorCode
EnhanceYourCalm     = ErrorCode 0xb

pattern InadequateSecurity :: ErrorCode
pattern $mInadequateSecurity :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bInadequateSecurity :: ErrorCode
InadequateSecurity  = ErrorCode 0xc

pattern HTTP11Required     :: ErrorCode
pattern $mHTTP11Required :: forall {r}. ErrorCode -> ((# #) -> r) -> ((# #) -> r) -> r
$bHTTP11Required :: ErrorCode
HTTP11Required      = ErrorCode 0xd
{- FOURMOLU_ENABLE -}

{- FOURMOLU_DISABLE -}
instance Show ErrorCode where
    show :: ErrorCode -> String
show ErrorCode
NoError            = String
"NoError"
    show ErrorCode
ProtocolError      = String
"ProtocolError"
    show ErrorCode
InternalError      = String
"InternalError"
    show ErrorCode
FlowControlError   = String
"FlowControlError"
    show ErrorCode
SettingsTimeout    = String
"SettingsTimeout"
    show ErrorCode
StreamClosed       = String
"StreamClosed"
    show ErrorCode
FrameSizeError     = String
"FrameSizeError"
    show ErrorCode
RefusedStream      = String
"RefusedStream"
    show ErrorCode
Cancel             = String
"Cancel"
    show ErrorCode
CompressionError   = String
"CompressionError"
    show ErrorCode
ConnectError       = String
"ConnectError"
    show ErrorCode
EnhanceYourCalm    = String
"EnhanceYourCalm"
    show ErrorCode
InadequateSecurity = String
"InadequateSecurity"
    show ErrorCode
HTTP11Required     = String
"HTTP11Required"
    show (ErrorCode Word32
x)      = String
"ErrorCode " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Word32 -> String
forall a. Show a => a -> String
show Word32
x
{- FOURMOLU_ENABLE -}

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

-- | The type for SETTINGS key.
newtype SettingsKey = SettingsKey Word16 deriving (SettingsKey -> SettingsKey -> Bool
(SettingsKey -> SettingsKey -> Bool)
-> (SettingsKey -> SettingsKey -> Bool) -> Eq SettingsKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SettingsKey -> SettingsKey -> Bool
== :: SettingsKey -> SettingsKey -> Bool
$c/= :: SettingsKey -> SettingsKey -> Bool
/= :: SettingsKey -> SettingsKey -> Bool
Eq, Eq SettingsKey
Eq SettingsKey =>
(SettingsKey -> SettingsKey -> Ordering)
-> (SettingsKey -> SettingsKey -> Bool)
-> (SettingsKey -> SettingsKey -> Bool)
-> (SettingsKey -> SettingsKey -> Bool)
-> (SettingsKey -> SettingsKey -> Bool)
-> (SettingsKey -> SettingsKey -> SettingsKey)
-> (SettingsKey -> SettingsKey -> SettingsKey)
-> Ord SettingsKey
SettingsKey -> SettingsKey -> Bool
SettingsKey -> SettingsKey -> Ordering
SettingsKey -> SettingsKey -> SettingsKey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: SettingsKey -> SettingsKey -> Ordering
compare :: SettingsKey -> SettingsKey -> Ordering
$c< :: SettingsKey -> SettingsKey -> Bool
< :: SettingsKey -> SettingsKey -> Bool
$c<= :: SettingsKey -> SettingsKey -> Bool
<= :: SettingsKey -> SettingsKey -> Bool
$c> :: SettingsKey -> SettingsKey -> Bool
> :: SettingsKey -> SettingsKey -> Bool
$c>= :: SettingsKey -> SettingsKey -> Bool
>= :: SettingsKey -> SettingsKey -> Bool
$cmax :: SettingsKey -> SettingsKey -> SettingsKey
max :: SettingsKey -> SettingsKey -> SettingsKey
$cmin :: SettingsKey -> SettingsKey -> SettingsKey
min :: SettingsKey -> SettingsKey -> SettingsKey
Ord)

fromSettingsKey :: SettingsKey -> Word16
fromSettingsKey :: SettingsKey -> Word16
fromSettingsKey (SettingsKey Word16
x) = Word16
x

toSettingsKey :: Word16 -> SettingsKey
toSettingsKey :: Word16 -> SettingsKey
toSettingsKey = Word16 -> SettingsKey
SettingsKey

minSettingsKey :: SettingsKey
minSettingsKey :: SettingsKey
minSettingsKey = Word16 -> SettingsKey
SettingsKey Word16
1

maxSettingsKey :: SettingsKey
maxSettingsKey :: SettingsKey
maxSettingsKey = Word16 -> SettingsKey
SettingsKey Word16
6

{- FOURMOLU_DISABLE -}
pattern SettingsHeaderTableSize      :: SettingsKey
pattern $mSettingsHeaderTableSize :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
$bSettingsHeaderTableSize :: SettingsKey
SettingsHeaderTableSize       = SettingsKey 1

pattern SettingsEnablePush           :: SettingsKey
pattern $mSettingsEnablePush :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
$bSettingsEnablePush :: SettingsKey
SettingsEnablePush            = SettingsKey 2

pattern SettingsMaxConcurrentStreams :: SettingsKey
pattern $mSettingsMaxConcurrentStreams :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
$bSettingsMaxConcurrentStreams :: SettingsKey
SettingsMaxConcurrentStreams  = SettingsKey 3

pattern SettingsInitialWindowSize    :: SettingsKey
pattern $mSettingsInitialWindowSize :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
$bSettingsInitialWindowSize :: SettingsKey
SettingsInitialWindowSize     = SettingsKey 4

pattern SettingsMaxFrameSize         :: SettingsKey
pattern $mSettingsMaxFrameSize :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
$bSettingsMaxFrameSize :: SettingsKey
SettingsMaxFrameSize          = SettingsKey 5 -- this means payload size

pattern SettingsMaxHeaderListSize    :: SettingsKey
pattern $mSettingsMaxHeaderListSize :: forall {r}. SettingsKey -> ((# #) -> r) -> ((# #) -> r) -> r
$bSettingsMaxHeaderListSize :: SettingsKey
SettingsMaxHeaderListSize     = SettingsKey 6
{- FOURMOLU_ENABLE -}

{- FOURMOLU_DISABLE -}
instance Show SettingsKey where
    show :: SettingsKey -> String
show SettingsKey
SettingsHeaderTableSize      = String
"SettingsHeaderTableSize"
    show SettingsKey
SettingsEnablePush           = String
"SettingsEnablePush"
    show SettingsKey
SettingsMaxConcurrentStreams = String
"SettingsMaxConcurrentStreams"
    show SettingsKey
SettingsInitialWindowSize    = String
"SettingsInitialWindowSize"
    show SettingsKey
SettingsMaxFrameSize         = String
"SettingsMaxFrameSize"
    show SettingsKey
SettingsMaxHeaderListSize    = String
"SettingsMaxHeaderListSize"
    show (SettingsKey Word16
x)              = String
"SettingsKey " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Word16 -> String
forall a. Show a => a -> String
show Word16
x
{- FOURMOLU_ENABLE -}

instance Read SettingsKey where
    readListPrec :: ReadPrec [SettingsKey]
readListPrec = ReadPrec [SettingsKey]
forall a. Read a => ReadPrec [a]
readListPrecDefault
    readPrec :: ReadPrec SettingsKey
readPrec = do
        Ident String
idnt <- ReadPrec Lexeme
lexP
        String -> ReadPrec SettingsKey
forall {a}. (Eq a, IsString a) => a -> ReadPrec SettingsKey
readSK String
idnt
      where
        readSK :: a -> ReadPrec SettingsKey
readSK a
"SettingsHeaderTableSize" = SettingsKey -> ReadPrec SettingsKey
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsHeaderTableSize
        readSK a
"SettingsEnablePush" = SettingsKey -> ReadPrec SettingsKey
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsEnablePush
        readSK a
"SettingsMaxConcurrentStreams" = SettingsKey -> ReadPrec SettingsKey
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsMaxConcurrentStreams
        readSK a
"SettingsInitialWindowSize" = SettingsKey -> ReadPrec SettingsKey
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsInitialWindowSize
        readSK a
"SettingsMaxFrameSize" = SettingsKey -> ReadPrec SettingsKey
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsMaxFrameSize
        readSK a
"SettingsMaxHeaderListSize" = SettingsKey -> ReadPrec SettingsKey
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return SettingsKey
SettingsMaxHeaderListSize
        readSK a
"SettingsKey" = do
            Number Number
ftyp <- ReadPrec Lexeme
lexP
            SettingsKey -> ReadPrec SettingsKey
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return (SettingsKey -> ReadPrec SettingsKey)
-> SettingsKey -> ReadPrec SettingsKey
forall a b. (a -> b) -> a -> b
$ Word16 -> SettingsKey
SettingsKey (Word16 -> SettingsKey) -> Word16 -> SettingsKey
forall a b. (a -> b) -> a -> b
$ Integer -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Word16) -> Integer -> Word16
forall a b. (a -> b) -> a -> b
$ Maybe Integer -> Integer
forall a. HasCallStack => Maybe a -> a
fromJust (Maybe Integer -> Integer) -> Maybe Integer -> Integer
forall a b. (a -> b) -> a -> b
$ Number -> Maybe Integer
L.numberToInteger Number
ftyp
        readSK a
_ = String -> ReadPrec SettingsKey
forall a. HasCallStack => String -> a
error String
"Read for SettingsKey"

-- | The type for raw SETTINGS value.
type SettingsValue = Int -- Word32

-- | Association list of SETTINGS.
type SettingsList = [(SettingsKey, SettingsValue)]

-- | The default initial window size.
--
-- >>> defaultWindowSize
-- 65535
defaultWindowSize :: WindowSize
defaultWindowSize :: StreamId
defaultWindowSize = StreamId
65535

-- | The maximum window size.
--
-- >>> maxWindowSize
-- 2147483647
maxWindowSize :: WindowSize
maxWindowSize :: StreamId
maxWindowSize = StreamId
2147483647

-- | Checking if a window size exceeds the maximum window size.
--
-- >>> isWindowOverflow 10
-- False
-- >>> isWindowOverflow maxWindowSize
-- False
-- >>> isWindowOverflow (maxWindowSize + 1)
-- True
isWindowOverflow :: WindowSize -> Bool
isWindowOverflow :: StreamId -> Bool
isWindowOverflow StreamId
w = StreamId -> StreamId -> Bool
forall a. Bits a => a -> StreamId -> Bool
testBit StreamId
w StreamId
31

-- | Default concurrency.
--
-- >>> recommendedConcurrency
-- 100
recommendedConcurrency :: Int
recommendedConcurrency :: StreamId
recommendedConcurrency = StreamId
100

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

-- | The type for weight in priority. Its values are from 1 to 256.
--   Deprecated in RFC 9113.
type Weight = Int

-- | Type for stream priority. Deprecated in RFC 9113 but provided for 'FrameHeaders'.
data Priority = Priority
    { Priority -> Bool
exclusive :: Bool
    , Priority -> StreamId
streamDependency :: StreamId
    , Priority -> StreamId
weight :: Weight
    }
    deriving (StreamId -> Priority -> ShowS
[Priority] -> ShowS
Priority -> String
(StreamId -> Priority -> ShowS)
-> (Priority -> String) -> ([Priority] -> ShowS) -> Show Priority
forall a.
(StreamId -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: StreamId -> Priority -> ShowS
showsPrec :: StreamId -> Priority -> ShowS
$cshow :: Priority -> String
show :: Priority -> String
$cshowList :: [Priority] -> ShowS
showList :: [Priority] -> ShowS
Show, ReadPrec [Priority]
ReadPrec Priority
StreamId -> ReadS Priority
ReadS [Priority]
(StreamId -> ReadS Priority)
-> ReadS [Priority]
-> ReadPrec Priority
-> ReadPrec [Priority]
-> Read Priority
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: StreamId -> ReadS Priority
readsPrec :: StreamId -> ReadS Priority
$creadList :: ReadS [Priority]
readList :: ReadS [Priority]
$creadPrec :: ReadPrec Priority
readPrec :: ReadPrec Priority
$creadListPrec :: ReadPrec [Priority]
readListPrec :: ReadPrec [Priority]
Read, Priority -> Priority -> Bool
(Priority -> Priority -> Bool)
-> (Priority -> Priority -> Bool) -> Eq Priority
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Priority -> Priority -> Bool
== :: Priority -> Priority -> Bool
$c/= :: Priority -> Priority -> Bool
/= :: Priority -> Priority -> Bool
Eq)

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

-- | The type for raw frame type.
newtype FrameType = FrameType Word8 deriving (FrameType -> FrameType -> Bool
(FrameType -> FrameType -> Bool)
-> (FrameType -> FrameType -> Bool) -> Eq FrameType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FrameType -> FrameType -> Bool
== :: FrameType -> FrameType -> Bool
$c/= :: FrameType -> FrameType -> Bool
/= :: FrameType -> FrameType -> Bool
Eq, Eq FrameType
Eq FrameType =>
(FrameType -> FrameType -> Ordering)
-> (FrameType -> FrameType -> Bool)
-> (FrameType -> FrameType -> Bool)
-> (FrameType -> FrameType -> Bool)
-> (FrameType -> FrameType -> Bool)
-> (FrameType -> FrameType -> FrameType)
-> (FrameType -> FrameType -> FrameType)
-> Ord FrameType
FrameType -> FrameType -> Bool
FrameType -> FrameType -> Ordering
FrameType -> FrameType -> FrameType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FrameType -> FrameType -> Ordering
compare :: FrameType -> FrameType -> Ordering
$c< :: FrameType -> FrameType -> Bool
< :: FrameType -> FrameType -> Bool
$c<= :: FrameType -> FrameType -> Bool
<= :: FrameType -> FrameType -> Bool
$c> :: FrameType -> FrameType -> Bool
> :: FrameType -> FrameType -> Bool
$c>= :: FrameType -> FrameType -> Bool
>= :: FrameType -> FrameType -> Bool
$cmax :: FrameType -> FrameType -> FrameType
max :: FrameType -> FrameType -> FrameType
$cmin :: FrameType -> FrameType -> FrameType
min :: FrameType -> FrameType -> FrameType
Ord, Ord FrameType
Ord FrameType =>
((FrameType, FrameType) -> [FrameType])
-> ((FrameType, FrameType) -> FrameType -> StreamId)
-> ((FrameType, FrameType) -> FrameType -> StreamId)
-> ((FrameType, FrameType) -> FrameType -> Bool)
-> ((FrameType, FrameType) -> StreamId)
-> ((FrameType, FrameType) -> StreamId)
-> Ix FrameType
(FrameType, FrameType) -> StreamId
(FrameType, FrameType) -> [FrameType]
(FrameType, FrameType) -> FrameType -> Bool
(FrameType, FrameType) -> FrameType -> StreamId
forall a.
Ord a =>
((a, a) -> [a])
-> ((a, a) -> a -> StreamId)
-> ((a, a) -> a -> StreamId)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> StreamId)
-> ((a, a) -> StreamId)
-> Ix a
$crange :: (FrameType, FrameType) -> [FrameType]
range :: (FrameType, FrameType) -> [FrameType]
$cindex :: (FrameType, FrameType) -> FrameType -> StreamId
index :: (FrameType, FrameType) -> FrameType -> StreamId
$cunsafeIndex :: (FrameType, FrameType) -> FrameType -> StreamId
unsafeIndex :: (FrameType, FrameType) -> FrameType -> StreamId
$cinRange :: (FrameType, FrameType) -> FrameType -> Bool
inRange :: (FrameType, FrameType) -> FrameType -> Bool
$crangeSize :: (FrameType, FrameType) -> StreamId
rangeSize :: (FrameType, FrameType) -> StreamId
$cunsafeRangeSize :: (FrameType, FrameType) -> StreamId
unsafeRangeSize :: (FrameType, FrameType) -> StreamId
Ix)

-- | Converting 'FrameType' to 'Word8'.
--
-- >>> fromFrameType FrameData
-- 0
-- >>> fromFrameType FrameContinuation
-- 9
fromFrameType :: FrameType -> Word8
fromFrameType :: FrameType -> FrameFlags
fromFrameType (FrameType FrameFlags
x) = FrameFlags
x

toFrameType :: Word8 -> FrameType
toFrameType :: FrameFlags -> FrameType
toFrameType = FrameFlags -> FrameType
FrameType

minFrameType :: FrameType
minFrameType :: FrameType
minFrameType = FrameFlags -> FrameType
FrameType FrameFlags
0

maxFrameType :: FrameType
maxFrameType :: FrameType
maxFrameType = FrameFlags -> FrameType
FrameType FrameFlags
9

{- FOURMOLU_DISABLE -}
pattern FrameData         :: FrameType
pattern $mFrameData :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFrameData :: FrameType
FrameData          = FrameType 0

pattern FrameHeaders      :: FrameType
pattern $mFrameHeaders :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFrameHeaders :: FrameType
FrameHeaders       = FrameType 1

pattern FramePriority     :: FrameType
pattern $mFramePriority :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFramePriority :: FrameType
FramePriority      = FrameType 2

pattern FrameRSTStream    :: FrameType
pattern $mFrameRSTStream :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFrameRSTStream :: FrameType
FrameRSTStream     = FrameType 3

pattern FrameSettings     :: FrameType
pattern $mFrameSettings :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFrameSettings :: FrameType
FrameSettings      = FrameType 4

pattern FramePushPromise  :: FrameType
pattern $mFramePushPromise :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFramePushPromise :: FrameType
FramePushPromise   = FrameType 5

pattern FramePing         :: FrameType
pattern $mFramePing :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFramePing :: FrameType
FramePing          = FrameType 6

pattern FrameGoAway       :: FrameType
pattern $mFrameGoAway :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFrameGoAway :: FrameType
FrameGoAway        = FrameType 7

pattern FrameWindowUpdate :: FrameType
pattern $mFrameWindowUpdate :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFrameWindowUpdate :: FrameType
FrameWindowUpdate  = FrameType 8

pattern FrameContinuation :: FrameType
pattern $mFrameContinuation :: forall {r}. FrameType -> ((# #) -> r) -> ((# #) -> r) -> r
$bFrameContinuation :: FrameType
FrameContinuation  = FrameType 9
{- FOURMOLU_ENABLE -}

{- FOURMOLU_DISABLE -}
instance Show FrameType where
    show :: FrameType -> String
show FrameType
FrameData         = String
"FrameData"
    show FrameType
FrameHeaders      = String
"FrameHeaders"
    show FrameType
FramePriority     = String
"FramePriority"
    show FrameType
FrameRSTStream    = String
"FrameRSTStream"
    show FrameType
FrameSettings     = String
"FrameSettings"
    show FrameType
FramePushPromise  = String
"FramePushPromise"
    show FrameType
FramePing         = String
"FramePing"
    show FrameType
FrameGoAway       = String
"FrameGoAway"
    show FrameType
FrameWindowUpdate = String
"FrameWindowUpdate"
    show FrameType
FrameContinuation = String
"FrameContinuation"
    show (FrameType FrameFlags
x)     = String
"FrameType " String -> ShowS
forall a. [a] -> [a] -> [a]
++ FrameFlags -> String
forall a. Show a => a -> String
show FrameFlags
x
{- FOURMOLU_ENABLE -}

{- FOURMOLU_DISABLE -}
instance Read FrameType where
    readListPrec :: ReadPrec [FrameType]
readListPrec = ReadPrec [FrameType]
forall a. Read a => ReadPrec [a]
readListPrecDefault
    readPrec :: ReadPrec FrameType
readPrec = do
        Ident String
idnt <- ReadPrec Lexeme
lexP
        String -> ReadPrec FrameType
forall {a}. (Eq a, IsString a) => a -> ReadPrec FrameType
readFT String
idnt
      where
        readFT :: a -> ReadPrec FrameType
readFT a
"FrameData"         = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameData
        readFT a
"FrameHeaders"      = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameHeaders
        readFT a
"FramePriority"     = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FramePriority
        readFT a
"FrameRSTStream"    = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameRSTStream
        readFT a
"FrameSettings"     = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameSettings
        readFT a
"FramePushPromise"  = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FramePushPromise
        readFT a
"FramePing"         = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FramePing
        readFT a
"FrameGoAway"       = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameGoAway
        readFT a
"FrameWindowUpdate" = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameWindowUpdate
        readFT a
"FrameContinuation" = FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameType
FrameContinuation
        readFT a
"FrameType"         = do
              Number Number
ftyp <- ReadPrec Lexeme
lexP
              FrameType -> ReadPrec FrameType
forall a. a -> ReadPrec a
forall (m :: * -> *) a. Monad m => a -> m a
return (FrameType -> ReadPrec FrameType)
-> FrameType -> ReadPrec FrameType
forall a b. (a -> b) -> a -> b
$ FrameFlags -> FrameType
FrameType (FrameFlags -> FrameType) -> FrameFlags -> FrameType
forall a b. (a -> b) -> a -> b
$ Integer -> FrameFlags
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> FrameFlags) -> Integer -> FrameFlags
forall a b. (a -> b) -> a -> b
$ Maybe Integer -> Integer
forall a. HasCallStack => Maybe a -> a
fromJust (Maybe Integer -> Integer) -> Maybe Integer -> Integer
forall a b. (a -> b) -> a -> b
$ Number -> Maybe Integer
L.numberToInteger Number
ftyp
        readFT a
_                   = String -> ReadPrec FrameType
forall a. HasCallStack => String -> a
error String
"Read for FrameType"
{- FOURMOLU_ENABLE -}

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

-- | The maximum payload length of HTTP/2 payload.
--
-- >>> maxPayloadLength
-- 16777215
maxPayloadLength :: Int
maxPayloadLength :: StreamId
maxPayloadLength = StreamId
2 StreamId -> StreamId -> StreamId
forall a b. (Num a, Integral b) => a -> b -> a
^ (StreamId
24 :: Int) StreamId -> StreamId -> StreamId
forall a. Num a => a -> a -> a
- StreamId
1

-- | The default payload length of HTTP/2 payload.
--
-- >>> defaultPayloadLength
-- 16384
defaultPayloadLength :: Int
defaultPayloadLength :: StreamId
defaultPayloadLength = StreamId
2 StreamId -> StreamId -> StreamId
forall a b. (Num a, Integral b) => a -> b -> a
^ (StreamId
14 :: Int)

----------------------------------------------------------------
-- Flags

-- | The type for flags.
type FrameFlags = Word8

-- | The initial value of flags. No flags are set.
--
-- >>> defaultFlags
-- 0
defaultFlags :: FrameFlags
defaultFlags :: FrameFlags
defaultFlags = FrameFlags
0

-- | Checking if the END_STREAM flag is set.
-- >>> testEndStream 0x1
-- True
testEndStream :: FrameFlags -> Bool
testEndStream :: FrameFlags -> Bool
testEndStream FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> Bool
forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
0

-- | Checking if the ACK flag is set.
-- >>> testAck 0x1
-- True
testAck :: FrameFlags -> Bool
testAck :: FrameFlags -> Bool
testAck FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> Bool
forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
0 -- fixme: is the spec intentional?

-- | Checking if the END_HEADERS flag is set.
--
-- >>> testEndHeader 0x4
-- True
testEndHeader :: FrameFlags -> Bool
testEndHeader :: FrameFlags -> Bool
testEndHeader FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> Bool
forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
2

-- | Checking if the PADDED flag is set.
--
-- >>> testPadded 0x8
-- True
testPadded :: FrameFlags -> Bool
testPadded :: FrameFlags -> Bool
testPadded FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> Bool
forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
3

-- | Checking if the PRIORITY flag is set.
--
-- >>> testPriority 0x20
-- True
testPriority :: FrameFlags -> Bool
testPriority :: FrameFlags -> Bool
testPriority FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> Bool
forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
5

-- | Setting the END_STREAM flag.
--
-- >>> setEndStream 0
-- 1
setEndStream :: FrameFlags -> FrameFlags
setEndStream :: FrameFlags -> FrameFlags
setEndStream FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> FrameFlags
forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
0

-- | Setting the ACK flag.
--
-- >>> setAck 0
-- 1
setAck :: FrameFlags -> FrameFlags
setAck :: FrameFlags -> FrameFlags
setAck FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> FrameFlags
forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
0 -- fixme: is the spec intentional?

-- | Setting the END_HEADERS flag.
--
-- >>> setEndHeader 0
-- 4
setEndHeader :: FrameFlags -> FrameFlags
setEndHeader :: FrameFlags -> FrameFlags
setEndHeader FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> FrameFlags
forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
2

-- | Setting the PADDED flag.
--
-- >>> setPadded 0
-- 8
setPadded :: FrameFlags -> FrameFlags
setPadded :: FrameFlags -> FrameFlags
setPadded FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> FrameFlags
forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
3

-- | Setting the PRIORITY flag.
--
-- >>> setPriority 0
-- 32
setPriority :: FrameFlags -> FrameFlags
setPriority :: FrameFlags -> FrameFlags
setPriority FrameFlags
x = FrameFlags
x FrameFlags -> StreamId -> FrameFlags
forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
5

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

-- | The type for stream identifier
type StreamId = Int

-- | Checking if the stream identifier for control.
--
-- >>> isControl 0
-- True
-- >>> isControl 1
-- False
isControl :: StreamId -> Bool
isControl :: StreamId -> Bool
isControl StreamId
0 = Bool
True
isControl StreamId
_ = Bool
False

-- | Checking if the stream identifier is from a client.
--
-- >>> isClientInitiated 0
-- False
-- >>> isClientInitiated 1
-- True
isClientInitiated :: StreamId -> Bool
isClientInitiated :: StreamId -> Bool
isClientInitiated = StreamId -> Bool
forall a. Integral a => a -> Bool
odd

-- | Checking if the stream identifier is from a server.
--
-- >>> isServerInitiated 0
-- False
-- >>> isServerInitiated 2
-- True
isServerInitiated :: StreamId -> Bool
isServerInitiated :: StreamId -> Bool
isServerInitiated StreamId
0 = Bool
False
isServerInitiated StreamId
n = StreamId -> Bool
forall a. Integral a => a -> Bool
even StreamId
n

-- | Checking if the exclusive flag is set.
testExclusive :: StreamId -> Bool
testExclusive :: StreamId -> Bool
testExclusive StreamId
n = StreamId
n StreamId -> StreamId -> Bool
forall a. Bits a => a -> StreamId -> Bool
`testBit` StreamId
31

-- | Setting the exclusive flag.
setExclusive :: StreamId -> StreamId
setExclusive :: StreamId -> StreamId
setExclusive StreamId
n = StreamId
n StreamId -> StreamId -> StreamId
forall a. Bits a => a -> StreamId -> a
`setBit` StreamId
31

-- | Clearing the exclusive flag.
clearExclusive :: StreamId -> StreamId
clearExclusive :: StreamId -> StreamId
clearExclusive StreamId
n = StreamId
n StreamId -> StreamId -> StreamId
forall a. Bits a => a -> StreamId -> a
`clearBit` StreamId
31

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

-- | The type for fragments of a header encoded with HPACK.
type HeaderBlockFragment = ByteString

-- | The type for padding in payloads.
type Padding = ByteString

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

-- | The data type for HTTP/2 frames.
data Frame = Frame
    { Frame -> FrameHeader
frameHeader :: FrameHeader
    , Frame -> FramePayload
framePayload :: FramePayload
    }
    deriving (StreamId -> Frame -> ShowS
[Frame] -> ShowS
Frame -> String
(StreamId -> Frame -> ShowS)
-> (Frame -> String) -> ([Frame] -> ShowS) -> Show Frame
forall a.
(StreamId -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: StreamId -> Frame -> ShowS
showsPrec :: StreamId -> Frame -> ShowS
$cshow :: Frame -> String
show :: Frame -> String
$cshowList :: [Frame] -> ShowS
showList :: [Frame] -> ShowS
Show, ReadPrec [Frame]
ReadPrec Frame
StreamId -> ReadS Frame
ReadS [Frame]
(StreamId -> ReadS Frame)
-> ReadS [Frame]
-> ReadPrec Frame
-> ReadPrec [Frame]
-> Read Frame
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: StreamId -> ReadS Frame
readsPrec :: StreamId -> ReadS Frame
$creadList :: ReadS [Frame]
readList :: ReadS [Frame]
$creadPrec :: ReadPrec Frame
readPrec :: ReadPrec Frame
$creadListPrec :: ReadPrec [Frame]
readListPrec :: ReadPrec [Frame]
Read, Frame -> Frame -> Bool
(Frame -> Frame -> Bool) -> (Frame -> Frame -> Bool) -> Eq Frame
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Frame -> Frame -> Bool
== :: Frame -> Frame -> Bool
$c/= :: Frame -> Frame -> Bool
/= :: Frame -> Frame -> Bool
Eq)

-- | The data type for HTTP/2 frame headers.
data FrameHeader = FrameHeader
    { FrameHeader -> StreamId
payloadLength :: Int
    , FrameHeader -> FrameFlags
flags :: FrameFlags
    , FrameHeader -> StreamId
streamId :: StreamId
    }
    deriving (StreamId -> FrameHeader -> ShowS
[FrameHeader] -> ShowS
FrameHeader -> String
(StreamId -> FrameHeader -> ShowS)
-> (FrameHeader -> String)
-> ([FrameHeader] -> ShowS)
-> Show FrameHeader
forall a.
(StreamId -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: StreamId -> FrameHeader -> ShowS
showsPrec :: StreamId -> FrameHeader -> ShowS
$cshow :: FrameHeader -> String
show :: FrameHeader -> String
$cshowList :: [FrameHeader] -> ShowS
showList :: [FrameHeader] -> ShowS
Show, ReadPrec [FrameHeader]
ReadPrec FrameHeader
StreamId -> ReadS FrameHeader
ReadS [FrameHeader]
(StreamId -> ReadS FrameHeader)
-> ReadS [FrameHeader]
-> ReadPrec FrameHeader
-> ReadPrec [FrameHeader]
-> Read FrameHeader
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: StreamId -> ReadS FrameHeader
readsPrec :: StreamId -> ReadS FrameHeader
$creadList :: ReadS [FrameHeader]
readList :: ReadS [FrameHeader]
$creadPrec :: ReadPrec FrameHeader
readPrec :: ReadPrec FrameHeader
$creadListPrec :: ReadPrec [FrameHeader]
readListPrec :: ReadPrec [FrameHeader]
Read, FrameHeader -> FrameHeader -> Bool
(FrameHeader -> FrameHeader -> Bool)
-> (FrameHeader -> FrameHeader -> Bool) -> Eq FrameHeader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FrameHeader -> FrameHeader -> Bool
== :: FrameHeader -> FrameHeader -> Bool
$c/= :: FrameHeader -> FrameHeader -> Bool
/= :: FrameHeader -> FrameHeader -> Bool
Eq)

-- | The data type for HTTP/2 frame payloads.
data FramePayload
    = DataFrame ByteString
    | HeadersFrame (Maybe Priority) HeaderBlockFragment
    | PriorityFrame Priority
    | RSTStreamFrame ErrorCode
    | SettingsFrame SettingsList
    | PushPromiseFrame StreamId HeaderBlockFragment
    | PingFrame ByteString
    | GoAwayFrame {- the last -} StreamId ErrorCode ByteString
    | WindowUpdateFrame WindowSize
    | ContinuationFrame HeaderBlockFragment
    | UnknownFrame FrameType ByteString
    deriving (StreamId -> FramePayload -> ShowS
[FramePayload] -> ShowS
FramePayload -> String
(StreamId -> FramePayload -> ShowS)
-> (FramePayload -> String)
-> ([FramePayload] -> ShowS)
-> Show FramePayload
forall a.
(StreamId -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: StreamId -> FramePayload -> ShowS
showsPrec :: StreamId -> FramePayload -> ShowS
$cshow :: FramePayload -> String
show :: FramePayload -> String
$cshowList :: [FramePayload] -> ShowS
showList :: [FramePayload] -> ShowS
Show, ReadPrec [FramePayload]
ReadPrec FramePayload
StreamId -> ReadS FramePayload
ReadS [FramePayload]
(StreamId -> ReadS FramePayload)
-> ReadS [FramePayload]
-> ReadPrec FramePayload
-> ReadPrec [FramePayload]
-> Read FramePayload
forall a.
(StreamId -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: StreamId -> ReadS FramePayload
readsPrec :: StreamId -> ReadS FramePayload
$creadList :: ReadS [FramePayload]
readList :: ReadS [FramePayload]
$creadPrec :: ReadPrec FramePayload
readPrec :: ReadPrec FramePayload
$creadListPrec :: ReadPrec [FramePayload]
readListPrec :: ReadPrec [FramePayload]
Read, FramePayload -> FramePayload -> Bool
(FramePayload -> FramePayload -> Bool)
-> (FramePayload -> FramePayload -> Bool) -> Eq FramePayload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FramePayload -> FramePayload -> Bool
== :: FramePayload -> FramePayload -> Bool
$c/= :: FramePayload -> FramePayload -> Bool
/= :: FramePayload -> FramePayload -> Bool
Eq)

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

-- | Getting 'FrameType' from 'FramePayload'.
--
-- >>> framePayloadToFrameType (DataFrame "body")
-- FrameData
{- FOURMOLU_DISABLE -}
framePayloadToFrameType :: FramePayload -> FrameType
framePayloadToFrameType :: FramePayload -> FrameType
framePayloadToFrameType DataFrame{}          = FrameType
FrameData
framePayloadToFrameType HeadersFrame{}       = FrameType
FrameHeaders
framePayloadToFrameType PriorityFrame{}      = FrameType
FramePriority
framePayloadToFrameType RSTStreamFrame{}     = FrameType
FrameRSTStream
framePayloadToFrameType SettingsFrame{}      = FrameType
FrameSettings
framePayloadToFrameType PushPromiseFrame{}   = FrameType
FramePushPromise
framePayloadToFrameType PingFrame{}          = FrameType
FramePing
framePayloadToFrameType GoAwayFrame{}        = FrameType
FrameGoAway
framePayloadToFrameType WindowUpdateFrame{}  = FrameType
FrameWindowUpdate
framePayloadToFrameType ContinuationFrame{}  = FrameType
FrameContinuation
framePayloadToFrameType (UnknownFrame FrameType
ft ByteString
_)  = FrameType
ft
{- FOURMOLU_ENABLE -}

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

-- | Checking if padding is defined in this frame type.
--
-- >>> isPaddingDefined $ DataFrame ""
-- True
-- >>> isPaddingDefined $ PingFrame ""
-- False
{- FOURMOLU_DISABLE -}
isPaddingDefined :: FramePayload -> Bool
isPaddingDefined :: FramePayload -> Bool
isPaddingDefined DataFrame{}         = Bool
True
isPaddingDefined HeadersFrame{}      = Bool
True
isPaddingDefined PriorityFrame{}     = Bool
False
isPaddingDefined RSTStreamFrame{}    = Bool
False
isPaddingDefined SettingsFrame{}     = Bool
False
isPaddingDefined PushPromiseFrame{}  = Bool
True
isPaddingDefined PingFrame{}         = Bool
False
isPaddingDefined GoAwayFrame{}       = Bool
False
isPaddingDefined WindowUpdateFrame{} = Bool
False
isPaddingDefined ContinuationFrame{} = Bool
False
isPaddingDefined UnknownFrame{}      = Bool
False
{- FOURMOLU_ENABLE -}

----------------------------------------------------------------
-- Deprecated

{- FOURMOLU_DISABLE -}
type ErrorCodeId   = ErrorCode
type SettingsKeyId = SettingsKey
type FrameTypeId   = FrameType
{- FOURMOLU_ENABLE -}
{- DEPRECATED ErrorCodeId   "Use ErrorCode instead" -}
{- DEPRECATED SettingsKeyId "Use SettingsKey instead" -}
{- DEPRECATED FrameTypeId   "Use FrameType instead" -}