X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FETag.hs;h=76df18378bf3e48417dddd8c73dc6222b65d5136;hb=a362be1c8664306b970c32e1df9b62081498feb1;hp=f7ef8387c7044d02acc1451a7fa0e140c3197c60;hpb=ac2ff93f647d60d43ca3cc54eb776fe0f701ac9e;p=Lucu.git diff --git a/Network/HTTP/Lucu/ETag.hs b/Network/HTTP/Lucu/ETag.hs index f7ef838..76df183 100644 --- a/Network/HTTP/Lucu/ETag.hs +++ b/Network/HTTP/Lucu/ETag.hs @@ -2,7 +2,7 @@ OverloadedStrings , UnicodeSyntax #-} --- |Manipulation of entity tags. +-- |Entity tags module Network.HTTP.Lucu.ETag ( ETag(..) , parseETag @@ -10,8 +10,8 @@ module Network.HTTP.Lucu.ETag , strongETag , weakETag - , eTagP - , eTagListP + , eTag + , eTagList ) where import Control.Applicative @@ -24,17 +24,18 @@ import Network.HTTP.Lucu.Parser.Http hiding (token) import Network.HTTP.Lucu.Utils import Prelude.Unicode --- |An entity tag is made of a weakness flag and a opaque string. +-- |An entity tag consists of a weakness flag and an opaque string. data ETag = ETag { -- |The weakness flag. Weak tags looks like W\/\"blahblah\" and - -- strong tags are like \"blahblah\". + -- strong tags are like \"blahblah\". See: + -- etagIsWeak ∷ !Bool -- |An opaque string. Only characters from 0x20 (sp) to 0x7e (~) -- are allowed. , etagToken ∷ !Ascii } deriving (Eq, Show) --- |Convert an 'ETag' to 'AsciiBuilder'. +-- |Convert an 'ETag' to an 'AsciiBuilder'. printETag ∷ ETag → AsciiBuilder {-# INLINEABLE printETag #-} printETag et @@ -57,31 +58,33 @@ parseETag str where p ∷ Parser ETag {-# INLINE p #-} - p = do et ← eTagP + p = do et ← eTag endOfInput return et --- |This is equivalent to @'ETag' 'Prelude.False'@. If you want to --- generate an ETag from a file, try using +-- |This is equivalent to @'ETag' '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'@. +-- |This is equivalent to @'ETag' '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 +-- |'Parser' for an 'ETag'. +eTag ∷ Parser ETag +{-# INLINEABLE eTag #-} +eTag = 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" - return xs +-- |'Parser' for a list of 'ETag's. +eTagList ∷ Parser [ETag] +{-# INLINEABLE eTagList #-} +eTagList = do xs ← listOf eTag + when (null xs) $ + fail "empty list of ETags" + return xs