From: PHO Date: Wed, 21 Dec 2011 16:10:47 +0000 (+0900) Subject: StatusCode: modified again X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=8de439e0d2869f46e926d3132f6b1113201460e5;p=Lucu.git StatusCode: modified again --- diff --git a/Network/HTTP/Lucu/StatusCode/Internal.hs b/Network/HTTP/Lucu/StatusCode/Internal.hs index 3818856..e3122da 100644 --- a/Network/HTTP/Lucu/StatusCode/Internal.hs +++ b/Network/HTTP/Lucu/StatusCode/Internal.hs @@ -4,6 +4,7 @@ , MultiParamTypeClasses , OverlappingInstances , TemplateHaskell + , UndecidableInstances , UnicodeSyntax , ViewPatterns #-} @@ -38,7 +39,7 @@ import Prelude.Unicode -- 'statusCodes' quasi-quoter. -- -- Minimal complete definition: 'numericCode' and 'textualStatus'. -class (Eq sc, Show sc) ⇒ StatusCode sc where +class Show sc ⇒ StatusCode sc where -- |Return the 3-digit integer for this status e.g. @200@ numericCode ∷ sc → Int -- |Return the combination of 3-digit integer and reason phrase @@ -48,13 +49,13 @@ class (Eq sc, Show sc) ⇒ StatusCode sc where fromStatusCode ∷ sc → SomeStatusCode fromStatusCode = SomeStatusCode +instance StatusCode sc ⇒ Eq sc where + (==) = (≈) + -- |Container type for the 'StatusCode' type class. data SomeStatusCode = ∀sc. StatusCode sc ⇒ SomeStatusCode sc -instance Eq SomeStatusCode where - (==) = (≈) - instance Show SomeStatusCode where show (SomeStatusCode sc) = show sc @@ -110,17 +111,17 @@ instance StatusCode sc ⇒ ConvertAttempt sc AsciiBuilder where -- becomes: -- -- @ --- data OK = OK deriving ('Eq', 'Show') +-- data OK = OK deriving ('Show') -- instance OK where -- 'numericCode' _ = 200 -- 'textualStatus' _ = 'cs' (\"200 OK\" ∷ Ascii) -- --- data BadRequest = BadRequest deriving ('Eq', 'Show') +-- data BadRequest = BadRequest deriving ('Show') -- instance BadRequest where -- 'numericCode' _ = 400 -- 'textualStatus' _ = 'cs' (\"400 Bad Request\" ∷ Ascii) -- --- data MethodNotAllowed = MethodNotAllowed deriving ('Eq', 'Show') +-- data MethodNotAllowed = MethodNotAllowed deriving ('Show') -- instance MethodNotAllowed where -- 'numericCode' _ = 405 -- 'textualStatus' _ = 'cs' (\"405 Method Not Allowed\" ∷ Ascii) @@ -178,7 +179,7 @@ statusDecl (num, phrase) name = mkName $ concatMap cs phrase dataDecl ∷ Q Dec - dataDecl = dataD (cxt []) name [] [con] [''Eq, ''Show] + dataDecl = dataD (cxt []) name [] [con] [''Show] instanceDecl ∷ Q [Dec] instanceDecl