{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NoFieldSelectors #-}

-- | Records that bundle the 'Okapi.Tree.SymTree' codecs for each part of an
--   HTTP request or response into a single value.
module Okapi.Record.Tree where

import Okapi.Tree (SymTree)
import Okapi.HTTP.Request.Method (Method)
import Okapi.HTTP.Request.Path (Path)
import Okapi.HTTP.Request.Query (Query)
import Okapi.HTTP.Request.Headers qualified as Request (Headers)
import Okapi.HTTP.Request.Body qualified as Request (Body)
import Okapi.HTTP.Response.Status (Status)
import Okapi.HTTP.Response.Headers qualified as Response (Headers)
import Okapi.HTTP.Response.Body qualified as Response (Body)

-- | Codecs for every part of an HTTP request.
data Request method path query headers body = Request
    { forall method path query headers body.
Request method path query headers body -> Method method
method  :: Method method
    , forall method path query headers body.
Request method path query headers body -> SymTree Path path
path    :: SymTree Path path
    , forall method path query headers body.
Request method path query headers body -> SymTree Query query
query   :: SymTree Query query
    , forall method path query headers body.
Request method path query headers body -> SymTree Headers headers
headers :: SymTree Request.Headers headers
    , forall method path query headers body.
Request method path query headers body -> SymTree Body body
body    :: SymTree Request.Body body
    }

-- | Codecs for every part of an HTTP response.
data Response status headers body = Response
    { forall status headers body.
Response status headers body -> Status status
status  :: Status status
    , forall status headers body.
Response status headers body -> SymTree Headers headers
headers :: SymTree Response.Headers headers
    , forall status headers body.
Response status headers body -> SymTree Body body
body    :: SymTree Response.Body body
    }