]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Implant/PrettyPrint.hs
Rename: Resource --> Rsrc; ResourceDef --> Resource
[Lucu.git] / Network / HTTP / Lucu / Implant / PrettyPrint.hs
index ecdb4fe8aed35dacc39f1f4234060d366cc1a070..c79b4d4b004c5526bd5f605f1c2324389fa3391c 100644 (file)
@@ -18,8 +18,8 @@ import Data.Ascii (CIAscii)
 import qualified Data.Ascii as A
 import qualified Data.ByteString.Lazy as L
 import Data.Char
-import Data.Foldable
-import Data.List
+import Data.Collections
+import Data.List (intersperse)
 import Data.Ratio
 import Data.Time
 import Language.Haskell.TH.Lib
@@ -30,8 +30,9 @@ import Network.HTTP.Lucu.ETag
 import Network.HTTP.Lucu.Implant
 import Network.HTTP.Lucu.Implant.Rewrite
 import Network.HTTP.Lucu.MIMEType
+import Network.HTTP.Lucu.OrphanInstances ()
 import Network.HTTP.Lucu.Resource
-import Network.HTTP.Lucu.Utils
+import Prelude hiding (head)
 import Prelude.Unicode
 
 header ∷ Input → Doc
@@ -79,8 +80,8 @@ moduleDecl modName symName
                    , text "where"
                    ])
 
-importDecls ∷ Imports ImportOp → Doc
-importDecls = vcat ∘ map pprImport ∘ toList
+importDecls ∷ Imports → Doc
+importDecls = vcat ∘ map pprImport ∘ fromFoldable
 
 pprImport ∷ ImportOp → Doc
 pprImport (QualifiedImp {..})
@@ -100,7 +101,7 @@ pprImport (UnqualifiedImp {impNames = Just ns, ..})
            , hcat [ lparen
                   , sep $ punctuate comma
                         $ map (uncurry pprImpName)
-                        $ toList ns
+                        $ fromFoldable ns
                   , rparen
                   ]
            ]
@@ -138,14 +139,14 @@ gzipEncoding = mkName "gzipEncoding"
 
 resourceDecl ∷ Input → Name → Q [Dec]
 resourceDecl i symName
-    = sequence [ sigD symName [t| ResourceDef |]
+    = sequence [ sigD symName [t| Resource |]
                , valD (varP symName) (normalB (resourceE i)) decls
                ]
     where
       decls ∷ [Q Dec]
       decls | useGZip i
                 = [ sigD gzipEncoding [t| CIAscii |]
-                  , valD (varP gzipEncoding) (normalB (liftCIAscii "gzip")) []
+                  , valD (varP gzipEncoding) (normalB (lift ("gzip" ∷ CIAscii))) []
                   ]
             | otherwise
                 = []
@@ -203,7 +204,7 @@ eTagDecl (Input {..})
 lastModDecl ∷ Input → Q [Dec]
 lastModDecl (Input {..})
     = sequence [ sigD lastModified [t| UTCTime |]
-               , valD (varP lastModified) (normalB (liftUTCTime iLastMod)) []
+               , valD (varP lastModified) (normalB (lift iLastMod)) []
                ]
 
 contTypeDecl ∷ Input → Q [Dec]
@@ -216,11 +217,11 @@ binDecl ∷ Input → Q [Dec]
 binDecl i@(Input {..})
     | useGZip i
         = sequence [ sigD gzippedData [t| L.ByteString |]
-                   , valD (varP gzippedData) (normalB (liftLazyByteString iGZipped)) []
+                   , valD (varP gzippedData) (normalB (lift iGZipped)) []
                    ]
     | otherwise
         = sequence [ sigD rawData [t| L.ByteString |]
-                   , valD (varP rawData) (normalB (liftLazyByteString iRawData)) []
+                   , valD (varP rawData) (normalB (lift iRawData)) []
                    ]
 
 rules ∷ Rules
@@ -229,7 +230,8 @@ rules = [ qualifyAll   "Codec.Compression.GZip"              "G"
         , qualifyAll   "Data.Ascii"                          "A"
         , qualifyAll   "Data.ByteString.Char8"               "B"
         , qualifyAll   "Data.ByteString.Lazy.Internal"       "L"
-        , qualifyAll   "Data.Map"                            "M"
+        , qualifyAll   "Data.CaseInsensitive"                "CI"
+        , qualifyAll   "Data.Collections"                    "C"
         , qualifyAll   "Data.Text"                           "T"
         , unqualifyAll "Network.HTTP.Lucu.ETag"              "Network.HTTP.Lucu"
         , unqualifyAll "Network.HTTP.Lucu.Resource"          "Network.HTTP.Lucu"