From 38462ddf67732513c21b348cffb7cae436800339 Mon Sep 17 00:00:00 2001 From: PHO Date: Mon, 7 Nov 2011 07:57:52 +0900 Subject: [PATCH 1/1] Haddock comments Ditz-issue: c566a8433e8af700655680f53e99cfe9f563ed32 --- Network/HTTP/Lucu.hs | 2 +- Network/HTTP/Lucu/Response.hs | 1 + Network/HTTP/Lucu/StatusCode/Internal.hs | 38 ++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Network/HTTP/Lucu.hs b/Network/HTTP/Lucu.hs index 3579c5c..79ae061 100644 --- a/Network/HTTP/Lucu.hs +++ b/Network/HTTP/Lucu.hs @@ -43,7 +43,7 @@ module Network.HTTP.Lucu , module Network.HTTP.Lucu.Resource -- ** Things to be used in the Resource monad - -- *** Status Code + -- *** 'StatusCode' , module Network.HTTP.Lucu.StatusCode -- *** 'Abortion' diff --git a/Network/HTTP/Lucu/Response.hs b/Network/HTTP/Lucu/Response.hs index cfff819..0ebfa71 100644 --- a/Network/HTTP/Lucu/Response.hs +++ b/Network/HTTP/Lucu/Response.hs @@ -10,6 +10,7 @@ module Network.HTTP.Lucu.Response StatusCode(..) , SomeStatusCode(..) , Response(..) + , statusCodes , module Network.HTTP.Lucu.StatusCode -- * Functions diff --git a/Network/HTTP/Lucu/StatusCode/Internal.hs b/Network/HTTP/Lucu/StatusCode/Internal.hs index 9269c5d..3addcf2 100644 --- a/Network/HTTP/Lucu/StatusCode/Internal.hs +++ b/Network/HTTP/Lucu/StatusCode/Internal.hs @@ -28,6 +28,9 @@ import Prelude.Unicode -- |The type class for HTTP status codes. -- +-- Declaring types for each statuses is surely a pain. See: +-- 'statusCodes' +-- -- Minimal complete definition: 'numericCode' and 'textualStatus'. class (Eq sc, Show sc, Typeable sc) ⇒ StatusCode sc where -- |Return the 3-digit integer for this status e.g. @200@ @@ -42,7 +45,7 @@ class (Eq sc, Show sc, Typeable sc) ⇒ StatusCode sc where toStatusCode ∷ SomeStatusCode → Maybe sc toStatusCode (SomeStatusCode sc) = cast sc --- |FIXME: doc +-- |Container type for 'StatusCode' type class. data SomeStatusCode = ∀sc. StatusCode sc ⇒ SomeStatusCode sc deriving Typeable @@ -50,6 +53,8 @@ data SomeStatusCode instance Show SomeStatusCode where show (SomeStatusCode sc) = show sc +-- |Two 'StatusCode's @a@ and @b@ are said to be equivalent iff +-- @'numericCode' a == 'numericCode' b@. instance Eq SomeStatusCode where (SomeStatusCode α) == (SomeStatusCode β) = numericCode α ≡ numericCode β @@ -60,7 +65,36 @@ instance StatusCode SomeStatusCode where fromStatusCode = id toStatusCode = Just --- |FIXME: doc +-- |'QuasiQuoter' for 'StatusCode' declarations. +-- +-- Top-level splicing +-- +-- @ +-- ['statusCodes'| +-- 200 OK +-- 400 Bad Request +-- 405 Method Not Allowed +-- |] +-- @ +-- +-- becomes: +-- +-- @ +-- data OK = OK deriving ('Eq', 'Show', 'Typeable') +-- instance OK where +-- 'numericCode' _ = 200 +-- 'textualStatus' _ = 'A.unsafeFromString' \"200 OK\" +-- +-- data BadRequest = BadRequest deriving ('Eq', 'Show', 'Typeable') +-- instance BadRequest where +-- 'numericCode' _ = 400 +-- 'textualStatus' _ = 'A.unsafeFromString' \"400 Bad Request\" +-- +-- data MethodNotAllowed = MethodNotAllowed deriving ('Eq', 'Show', 'Typeable') +-- instance MethodNotAllowed where +-- 'numericCode' _ = 405 +-- 'textualStatus' _ = 'A.unsafeFromString' \"405 Method Not Allowed\" +-- @ statusCodes ∷ QuasiQuoter statusCodes = QuasiQuoter { quoteExp = const unsupported -- 2.40.0