Is there some way to determine the MIME type of a file by it's content ? Maybe with some Haskell library ?
Haskell bindings to libmagic might be a solution to your problem. Here's an example.
import Magic
import System.Environment (getArgs)
main = do
magic <- magicOpen [MagicMime]
(file:_) <- getArgs
magicLoadDefault magic
mime <- magicFile magic file
putStrLn mime