]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/ETag.hs
Examples now compile.
[Lucu.git] / Network / HTTP / Lucu / ETag.hs
index 9bfa9aa29e67555499dc62bfecfa3b8b8f97b04b..f7ef8387c7044d02acc1451a7fa0e140c3197c60 100644 (file)
@@ -36,6 +36,7 @@ data ETag = ETag {
 
 -- |Convert an 'ETag' to 'AsciiBuilder'.
 printETag ∷ ETag → AsciiBuilder
+{-# INLINEABLE printETag #-}
 printETag et
     = ( if etagIsWeak et then
             A.toAsciiBuilder "W/"
@@ -48,32 +49,38 @@ printETag et
 -- |Parse 'Etag' from an 'Ascii'. This functions throws an exception
 -- for parse error.
 parseETag ∷ Ascii → ETag
+{-# INLINEABLE parseETag #-}
 parseETag str
-    = let p  = do et ← eTagP
-                  endOfInput
-                  return et
-          bs = A.toByteString str
-      in
-        case parseOnly p bs of
-          Right et → et
-          Left err → error ("unparsable ETag: " ⧺ A.toString str ⧺ ": " ⧺ err)
+    = case parseOnly p $ A.toByteString str of
+        Right et → et
+        Left err → error ("unparsable ETag: " ⧺ A.toString str ⧺ ": " ⧺ err)
+    where
+      p ∷ Parser ETag
+      {-# INLINE p #-}
+      p = do et ← eTagP
+             endOfInput
+             return et
 
 -- |This is equivalent to @'ETag' 'Prelude.False'@. If you want to
 -- generate an ETag from a file, try using
 -- 'Network.HTTP.Lucu.StaticFile.generateETagFromFile'.
 strongETag ∷ Ascii → ETag
+{-# INLINE strongETag #-}
 strongETag = ETag False
 
 -- |This is equivalent to @'ETag' 'Prelude.True'@.
 weakETag ∷ Ascii → ETag
+{-# INLINE weakETag #-}
 weakETag = ETag True
 
 eTagP ∷ Parser ETag
+{-# INLINEABLE eTagP #-}
 eTagP = do isWeak ← option False (string "W/" *> return True)
            str    ← quotedStr
            return $ ETag isWeak str
 
 eTagListP ∷ Parser [ETag]
+{-# INLINEABLE eTagListP #-}
 eTagListP = do xs ← listOf eTagP
                when (null xs) $
                    fail "empty list of ETags"