    --------------------------------------------------------------------------------
    -- | A module dealing with pandoc file extensions and associated file types
    module Hakyll.Web.Pandoc.FileType
        ( FileType (..)
        , fileType
        , itemFileType
        ) where

    --------------------------------------------------------------------------------
    import           System.FilePath        (splitExtension)

    --------------------------------------------------------------------------------
    import           Hakyll.Core.Identifier
    import           Hakyll.Core.Item

    --------------------------------------------------------------------------------
    -- | Datatype to represent the different file types Hakyll can deal with by
    -- default
    data FileType
        = Binary
        | Css
        | DocBook
        | Html
        | Jupyter
        | LaTeX
        | LiterateHaskell FileType
        | Markdown
        | MediaWiki
        | OrgMode
        | PlainText
        | Rst
        | Textile
        deriving (FileType -> FileType -> Bool
    (FileType -> FileType -> Bool)
    -> (FileType -> FileType -> Bool) -> Eq FileType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FileType -> FileType -> Bool
    == :: FileType -> FileType -> Bool
    $c/= :: FileType -> FileType -> Bool
    /= :: FileType -> FileType -> Bool
    Eq, Eq FileType
    Eq FileType
    -> (FileType -> FileType -> Ordering)
    -> (FileType -> FileType -> Bool)
    -> (FileType -> FileType -> Bool)
    -> (FileType -> FileType -> Bool)
    -> (FileType -> FileType -> Bool)
    -> (FileType -> FileType -> FileType)
    -> (FileType -> FileType -> FileType)
    -> Ord FileType
    FileType -> FileType -> Bool
    FileType -> FileType -> Ordering
    FileType -> FileType -> FileType
    forall a.
    Eq a
    -> (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: FileType -> FileType -> Ordering
    compare :: FileType -> FileType -> Ordering
    $c< :: FileType -> FileType -> Bool
    < :: FileType -> FileType -> Bool
    $c<= :: FileType -> FileType -> Bool
    <= :: FileType -> FileType -> Bool
    $c> :: FileType -> FileType -> Bool
    > :: FileType -> FileType -> Bool
    $c>= :: FileType -> FileType -> Bool
    >= :: FileType -> FileType -> Bool
    $cmax :: FileType -> FileType -> FileType
    max :: FileType -> FileType -> FileType
    $cmin :: FileType -> FileType -> FileType
    min :: FileType -> FileType -> FileType
    Ord, Int -> FileType -> ShowS
    [FileType] -> ShowS
    FileType -> String
    (Int -> FileType -> ShowS)
    -> (FileType -> String) -> ([FileType] -> ShowS) -> Show FileType
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> FileType -> ShowS
    showsPrec :: Int -> FileType -> ShowS
    $cshow :: FileType -> String
    show :: FileType -> String
    $cshowList :: [FileType] -> ShowS
    showList :: [FileType] -> ShowS
    Show, ReadPrec [FileType]
    ReadPrec FileType
    Int -> ReadS FileType
    ReadS [FileType]
    (Int -> ReadS FileType)
    -> ReadS [FileType]
    -> ReadPrec FileType
    -> ReadPrec [FileType]
    -> Read FileType
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS FileType
    readsPrec :: Int -> ReadS FileType
    $creadList :: ReadS [FileType]
    readList :: ReadS [FileType]
    $creadPrec :: ReadPrec FileType
    readPrec :: ReadPrec FileType
    $creadListPrec :: ReadPrec [FileType]
    readListPrec :: ReadPrec [FileType]
    Read)

    --------------------------------------------------------------------------------
    -- | Get the file type for a certain file. The type is determined by extension.
    fileType :: FilePath -> FileType
    fileType :: String -> FileType
    fileType = (String -> String -> FileType) -> (String, String) -> FileType
    forall a b c. (a -> b -> c) -> (a, b) -> c
    uncurry String -> String -> FileType
    fileType' ((String, String) -> FileType)
    -> (String -> (String, String)) -> String -> FileType
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> (String, String)
    splitExtension
      where
        fileType' :: String -> String -> FileType
    fileType' String
    _ String
    ".css"       = FileType
    Css
        fileType' String
    _ String
    ".dbk"       = FileType
    DocBook
        fileType' String
    _ String
    ".ipynb"     = FileType
    Jupyter
        fileType' String
    _ String
    ".htm"       = FileType
    Html
        fileType' String
    _ String
    ".html"      = FileType
    Html
        fileType' String
    f String
    ".lhs"       = FileType -> FileType
    LiterateHaskell (FileType -> FileType) -> FileType -> FileType
    forall a b. (a -> b) -> a -> b
    $ case String -> FileType
    fileType String
    f of
            -- If no extension is given, default to Markdown + LiterateHaskell
            FileType
    Binary -> FileType
    Markdown
            -- Otherwise, LaTeX + LiterateHaskell or whatever the user specified
            FileType
    x      -> FileType
    x
        fileType' String
    _ String
    ".markdown"  = FileType
    Markdown
        fileType' String
    _ String
    ".mediawiki" = FileType
    MediaWiki
        fileType' String
    _ String
    ".md"        = FileType
    Markdown
        fileType' String
    _ String
    ".mdn"       = FileType
    Markdown
        fileType' String
    _ String
    ".mdown"     = FileType
    Markdown
        fileType' String
    _ String
    ".mdwn"      = FileType
    Markdown
        fileType' String
    _ String
    ".mkd"       = FileType
    Markdown
        fileType' String
    _ String
    ".mkdwn"     = FileType
    Markdown
        fileType' String
    _ String
    ".org"       = FileType
    OrgMode
        fileType' String
    _ String
    ".page"      = FileType
    Markdown
        fileType' String
    _ String
    ".rst"       = FileType
    Rst
        fileType' String
    _ String
    ".tex"       = FileType
    LaTeX
        fileType' String
    _ String
    ".text"      = FileType
    PlainText
        fileType' String
    _ String
    ".textile"   = FileType
    Textile
        fileType' String
    _ String
    ".txt"       = FileType
    PlainText
        fileType' String
    _ String
    ".wiki"      = FileType
    MediaWiki
        fileType' String
    _ String
    _            = FileType
    Binary  -- Treat unknown files as binary

    --------------------------------------------------------------------------------
    -- | Get the file type for the current file
    itemFileType :: Item a -> FileType
    itemFileType :: forall a. Item a -> FileType
    itemFileType = String -> FileType
    fileType (String -> FileType) -> (Item a -> String) -> Item a -> FileType
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Identifier -> String
    toFilePath (Identifier -> String)
    -> (Item a -> Identifier) -> Item a -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Item a -> Identifier
    forall a. Item a -> Identifier
    itemIdentifier