module Network.HPACK.Builder where

newtype Builder a = Builder ([a] -> [a])

(<<) :: Builder a -> a -> Builder a
Builder [a] -> [a]
b << :: Builder a -> a -> Builder a
<< a
entry = ([a] -> [a]) -> Builder a
forall a. ([a] -> [a]) -> Builder a
Builder (([a] -> [a]) -> Builder a) -> ([a] -> [a]) -> Builder a
forall a b. (a -> b) -> a -> b
$ [a] -> [a]
b ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a
entry a -> [a] -> [a]
forall a. a -> [a] -> [a]
:)

empty :: Builder a
empty :: Builder a
empty = ([a] -> [a]) -> Builder a
forall a. ([a] -> [a]) -> Builder a
Builder [a] -> [a]
forall a. a -> a
id

singleton :: a -> Builder a
singleton :: a -> Builder a
singleton a
x = ([a] -> [a]) -> Builder a
forall a. ([a] -> [a]) -> Builder a
Builder (a
x a -> [a] -> [a]
forall a. a -> [a] -> [a]
:)

run :: Builder a -> [a]
run :: Builder a -> [a]
run (Builder [a] -> [a]
b) = [a] -> [a]
b []