X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=ImplantFile.hs;h=b085a9876b859c4463c11609524da25082b48f4d;hp=3b80e60844d3835cda549d64b5bd99325d7b282f;hb=ac2ff93;hpb=fc4e0252eed3c9cb43c250ea7dd29ef5dffa6dad diff --git a/ImplantFile.hs b/ImplantFile.hs index 3b80e60..b085a98 100644 --- a/ImplantFile.hs +++ b/ImplantFile.hs @@ -182,21 +182,19 @@ resourceDecl symName useGZip resHead ∷ Exp resHead - = infixApp (var $ name "Just") - (op $ name "$" ) - (doE [ foundEntityStmt - , setContentTypeStmt - ]) + = function "Just" `app` + paren (doE [ foundEntityStmt + , setContentTypeStmt + ]) resGetGZipped ∷ Exp resGetGZipped - = infixApp (var $ name "Just") - (op $ name "$" ) - (doE [ foundEntityStmt - , setContentTypeStmt - , bindGZipStmt - , conditionalOutputStmt - ]) + = function "Just" `app` + paren (doE [ foundEntityStmt + , setContentTypeStmt + , bindGZipStmt + , conditionalOutputStmt + ]) where condVarName ∷ Name condVarName = name "gzipAllowed" @@ -208,7 +206,7 @@ resGetGZipped bindGZipStmt = genStmt (⊥) (pvar condVarName) - (metaFunction "isEncodingAcceptable" [strE "gzip"]) + (function "isEncodingAcceptable" `app` strE "gzip") conditionalOutputStmt ∷ Stmt conditionalOutputStmt @@ -217,23 +215,26 @@ resGetGZipped (doE [ setContentEncodingGZipStmt , outputStmt (var dataVarName) ]) - (metaFunction "output" - [paren (metaFunction "decompress" [var dataVarName])]) + ( function "output" + `app` + paren (function "decompress" `app` var dataVarName) + ) resGetRaw ∷ Exp resGetRaw - = infixApp (var $ name "Just") - (op $ name "$" ) - (doE [ foundEntityStmt - , setContentTypeStmt - , outputStmt (var $ name "rawData") - ]) + = function "Just" `app` + paren (doE [ foundEntityStmt + , setContentTypeStmt + , outputStmt (var $ name "rawData") + ]) setContentEncodingGZipStmt ∷ Stmt setContentEncodingGZipStmt - = qualStmt $ - metaFunction "setContentEncoding" - [ listE [ strE "gzip" ] ] + = qualStmt + ( function "setContentEncoding" + `app` + listE [ strE "gzip" ] + ) foundEntityStmt ∷ Stmt foundEntityStmt @@ -245,14 +246,15 @@ foundEntityStmt setContentTypeStmt ∷ Stmt setContentTypeStmt - = qualStmt $ - metaFunction "setContentType" - [var $ name "contentType"] + = qualStmt + ( function "setContentType" + `app` + var (name "contentType") + ) outputStmt ∷ Exp → Stmt outputStmt e - = qualStmt $ - metaFunction "output" [e] + = qualStmt $ function "output" `app` e entityTagDecl ∷ ETag → [Decl] entityTagDecl eTag @@ -264,7 +266,7 @@ entityTagDecl eTag varName = name "entityTag" valExp ∷ Exp - valExp = metaFunction "parseETag" [strE $ eTagToString eTag] + valExp = function "parseETag" `app` strE (eTagToString eTag) lastModifiedDecl ∷ UTCTime → [Decl] lastModifiedDecl lastMod @@ -276,7 +278,7 @@ lastModifiedDecl lastMod varName = name "lastModified" valExp ∷ Exp - valExp = metaFunction "read" [strE $ show lastMod] + valExp = function "read" `app` strE (show lastMod) contentTypeDecl ∷ MIMEType → [Decl] contentTypeDecl mime @@ -288,7 +290,7 @@ contentTypeDecl mime varName = name "contentType" valExp ∷ Exp - valExp = metaFunction "parseMIMEType" [strE $ mimeToString mime] + valExp = function "parseMIMEType" `app` strE (mimeToString mime) mimeToString ∷ MIMEType → String mimeToString = A.toString ∘ A.fromAsciiBuilder ∘ printMIMEType @@ -328,7 +330,7 @@ mkHeader srcFile originalLen gzippedLen useGZip mimeType eTag lastMod " Compression: gzip\n" else " Compression: disabled\n" - , " MIME Type: ", show mimeType, "\n" + , " MIME Type: ", mimeTypeToString mimeType, "\n" , " ETag: ", eTagToString eTag, "\n" , " Last Modified: ", show localLastMod, "\n" , " -}" @@ -337,6 +339,9 @@ mkHeader srcFile originalLen gzippedLen useGZip mimeType eTag lastMod eTagToString ∷ ETag → String eTagToString = A.toString ∘ A.fromAsciiBuilder ∘ printETag +mimeTypeToString ∷ MIMEType → String +mimeTypeToString = A.toString ∘ A.fromAsciiBuilder ∘ printMIMEType + getModuleName ∷ [CmdOpt] → IO ModuleName getModuleName opts = case modNameOpts of