This modules provides the union type MimeType to model some of the most common mime types and a parsing function that tries to parse a MimeType. The possible values for MimeType are all union types as well that specify the Sub-type. It was originally developed to classify files dropped into the browser via the HTML5 Drag and Drop api.
This library ATM provides only an incomplete, somewhat arbitrary mapping of the most common browser mime types. See https://code.google.com/p/chromium/codesearch#chromium/src/net/base/mime_util.cc&l=201 for a full list of Mime types as implemented in chromium.
Models the major types image, audio, video and text with a subtype or OtherMimeType
parseMimeType : String -> Maybe MimeType
Tries to parse the Mime type from a string.
-- normal use of a type/subtype that is modelled:
parseMimeType "image/jpeg" == Just (Image Jpeg)
-- use of a subtype that is not modelled ATM
parseMimeType "image/tiff" == Just (Image OtherImage)
-- use with an empty string
parseMimeType "" == Nothing
-- use with something else
parseMimeType "bla" == Just OtherMimeType
toString : MimeType -> String
Transforms a MimeType back to a string represenation. Note that this only works properly for correctly recognized mime types at the moment. A future version of this library will instead store the originally parsed mime type.
toString (Image Jpeg) == "image/jpeg"
Models the most common text subtypes
Models the most common image subtypes
Models the most common audio subtypes
Models the most common video subtypes
Models the most common app subtypes