From 2c3a52fc35159166c8064ae42a3067094849b240 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Thu, 19 Nov 2015 00:03:48 -0800 Subject: [PATCH] Cool person style for long comments --- src/PostgREST/RequestIntent.hs | 52 +++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/PostgREST/RequestIntent.hs b/src/PostgREST/RequestIntent.hs index a8e56eb94..29b01ad03 100644 --- a/src/PostgREST/RequestIntent.hs +++ b/src/PostgREST/RequestIntent.hs @@ -37,11 +37,13 @@ data ContentType = ApplicationJSON | TextCSV data Payload = PayloadJSON JSON.Array | PayloadParseError BS.ByteString --- | Describes what the user wants to do. This data type is a --- translation of the raw elements of an HTTP request into domain --- specific language. There is no guarantee that the intent is --- sensible, it is up to a later stage of processing to determine --- if it is an action we are able to perform. +{-| + Describes what the user wants to do. This data type is a + translation of the raw elements of an HTTP request into domain + specific language. There is no guarantee that the intent is + sensible, it is up to a later stage of processing to determine + if it is an action we are able to perform. +-} data Intent = Intent { -- | Set to Nothing for unknown HTTP verbs iAction :: Action @@ -112,14 +114,16 @@ userIntent schema req reqBody = -- PRIVATE --------------------------------------------------------------- --- | Picks a preferred content type from an Accept header (or from --- Content-Type as a degenerate case). --- --- For example --- text/csv -> TextCSV --- */* -> ApplicationJSON --- text/csv, application/json -> TextCSV --- application/json, text/csv -> ApplicationJSON +{-| + Picks a preferred content type from an Accept header (or from + Content-Type as a degenerate case). + + For example + text/csv -> TextCSV + */* -> ApplicationJSON + text/csv, application/json -> TextCSV + application/json, text/csv -> ApplicationJSON +-} pickContentType :: Maybe BS.ByteString -> Either BS.ByteString ContentType pickContentType accept | isNothing accept || has ctAll || has ctJson = Right ApplicationJSON @@ -135,16 +139,18 @@ pickContentType accept type CsvData = V.Vector (M.HashMap T.Text BL.ByteString) --- | Converts CSV like --- a,b --- 1,hi --- 2,bye --- --- into a JSON array like --- [ {"a": "1", "b": "hi"}, {"a": 2, "b": "bye"} ] --- --- The reason for its odd signature is so that it can compose --- directly with CSV.decodeByName +{-| + Converts CSV like + a,b + 1,hi + 2,bye + + into a JSON array like + [ {"a": "1", "b": "hi"}, {"a": 2, "b": "bye"} ] + + The reason for its odd signature is so that it can compose + directly with CSV.decodeByName +-} csvToJson :: (CSV.Header, CsvData) -> JSON.Array csvToJson (_, vals) = V.map rowToJsonObj vals