From 8de439e0d2869f46e926d3132f6b1113201460e5 Mon Sep 17 00:00:00 2001 From: PHO Date: Thu, 22 Dec 2011 01:10:47 +0900 Subject: [PATCH] StatusCode: modified again --- Network/HTTP/Lucu/StatusCode/Internal.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 -- 2.40.0