{-# LANGUAGE Rank2Types #-}

module Network.HTTP.Pony.Type where

import Data.ByteString (ByteString)
import Data.CaseInsensitive (CI)
import Network.Socket (Socket)
import Pipes (Producer)

type StartLine = ByteString
type Header = (CI ByteString, ByteString)

type Message a m r = (StartLine, [Header], Producer a m r)

type Request a m r = Message a m r
type Response a m r = Message a m r

-- App shouldn't block!
type Application m a b x y = Request a m x -> m (Response b m y)
type Application' m a x = Application m a a x x
type Application'' m a = Application m a a () ()

type App = Application'' IO ByteString

-- type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
-- A Middleware is a Lens on Message?

-- type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
type Middleware f s t a b = (a -> f b) -> s -> f t
type Middleware' f s t = (s -> f t) -> s -> f t