blob: 5356312c39cea88670fe0d102a118d7a8b05b5bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
module Common.Mime (getType, getSubtype, MimeType (..)) where
import Common (split2, trim)
import Intro
data MimeType = Text String | Image String | Application String
getType :: String -> Maybe MimeType
getType mime = case type_ of
"text" -> Just (Text subtype)
"image" -> Just (Image subtype)
"application" -> Just (Application subtype)
_ -> Nothing
where
(type_, subtype) = split2 (== '/') $ trim mime
getSubtype :: String -> String
getSubtype = trim . snd . split2 (== '/')
instance Show MimeType where
show (Text sub) = "text/" ++ sub
show (Image sub) = "image/" ++ sub
show (Application sub) = "application/" ++ sub
|