]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Implant/PrettyPrint.hs
Merge branch 'convertible'
[Lucu.git] / Network / HTTP / Lucu / Implant / PrettyPrint.hs
index f5376f1267631f0aa82faf378c5fb52069d0d975..22e3a74538c3a3342a74979c45d60382a3742c63 100644 (file)
@@ -1,5 +1,7 @@
 {-# LANGUAGE
     DoAndIfThenElse
+  , FlexibleContexts
+  , MultiParamTypeClasses
   , OverloadedStrings
   , RecordWildCards
   , TemplateHaskell
@@ -14,11 +16,12 @@ module Network.HTTP.Lucu.Implant.PrettyPrint
     where
 import Codec.Compression.GZip
 import Control.Monad
-import Data.Ascii (CIAscii)
-import qualified Data.Ascii as A
+import Data.Ascii (Ascii, CIAscii)
 import qualified Data.ByteString.Lazy as L
 import Data.Char
 import Data.Collections
+import Data.Convertible.Base
+import Data.Convertible.Utils
 import Data.List (intersperse)
 import Data.Monoid
 import Data.Ratio
@@ -59,19 +62,16 @@ header i@(Input {..})
                              ]
                     else
                         text "      Compression: disabled"
-                  , text "        MIME Type:" <+> mimeTypeToDoc iType
-                  , text "             ETag:" <+> eTagToDoc iETag
+                  , text "        MIME Type:" <+> toDoc iType
+                  , text "             ETag:" <+> toDoc iETag
                   , text "    Last Modified:" <+> text (show iLastMod)
                   ]
            , text " -}"
            , text "{-# LANGUAGE MagicHash #-}"
            ]
     where
-      eTagToDoc ∷ ETag → Doc
-      eTagToDoc = text ∘ A.toString ∘ A.fromAsciiBuilder ∘ printETag
-
-      mimeTypeToDoc ∷ MIMEType → Doc
-      mimeTypeToDoc = text ∘ A.toString ∘ A.fromAsciiBuilder ∘ printMIMEType
+      toDoc ∷ ConvertSuccess α Ascii ⇒ α → Doc
+      toDoc = text ∘ convertSuccessVia ((⊥) ∷ Ascii)
 
 moduleDecl ∷ ModName → Name → Doc
 moduleDecl modName symName