[yesod] Fix comment for contentTypeTypes & simpler implementation
In the implementation of contentTypeTypes make use of simpleContentType.
This commit is contained in:
parent
e2b0a5c454
commit
7f6f1821e8
@ -78,6 +78,7 @@ import Yesod.Core.Types
|
|||||||
import Text.Lucius (Css, renderCss)
|
import Text.Lucius (Css, renderCss)
|
||||||
import Text.Julius (Javascript, unJavascript)
|
import Text.Julius (Javascript, unJavascript)
|
||||||
import Data.Word8 (_semicolon, _slash)
|
import Data.Word8 (_semicolon, _slash)
|
||||||
|
import Control.Arrow (second)
|
||||||
|
|
||||||
-- | Zero-length enumerator.
|
-- | Zero-length enumerator.
|
||||||
emptyContent :: Content
|
emptyContent :: Content
|
||||||
@ -228,13 +229,13 @@ typeOctet = "application/octet-stream"
|
|||||||
simpleContentType :: ContentType -> ContentType
|
simpleContentType :: ContentType -> ContentType
|
||||||
simpleContentType = fst . B.break (== _semicolon)
|
simpleContentType = fst . B.break (== _semicolon)
|
||||||
|
|
||||||
-- Give just the media types as a pair.
|
-- | Give just the media types as a pair.
|
||||||
|
--
|
||||||
-- For example, \"text/html; charset=utf-8\" returns ("text", "html")
|
-- For example, \"text/html; charset=utf-8\" returns ("text", "html")
|
||||||
contentTypeTypes :: ContentType -> (B.ByteString, B.ByteString)
|
contentTypeTypes :: ContentType -> (B.ByteString, B.ByteString)
|
||||||
contentTypeTypes ct = (main, fst $ B.break (== _semicolon) (tailEmpty sub))
|
contentTypeTypes = second tailEmpty . B.break (== _slash) . simpleContentType
|
||||||
where
|
where
|
||||||
tailEmpty x = if B.null x then "" else B.tail x
|
tailEmpty x = if B.null x then "" else B.tail x
|
||||||
(main, sub) = B.break (== _slash) ct
|
|
||||||
|
|
||||||
instance HasContentType a => HasContentType (DontFullyEvaluate a) where
|
instance HasContentType a => HasContentType (DontFullyEvaluate a) where
|
||||||
getContentType = getContentType . liftM unDontFullyEvaluate
|
getContentType = getContentType . liftM unDontFullyEvaluate
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user