{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeApplications #-}
module Headroom.FileType
( configByFileType
, fileTypeByExt
, listExtensions
)
where
import Headroom.Configuration.Types ( CtHeaderConfig
, CtHeadersConfig
, HeaderConfig(..)
, HeadersConfig(..)
)
import Headroom.Data.EnumExtra ( EnumExtra(..) )
import Headroom.FileType.Types ( FileType(..) )
import RIO
import qualified RIO.List as L
fileTypeByExt :: CtHeadersConfig
-> Text
-> Maybe FileType
fileTypeByExt config ext =
L.find (elem ext . listExtensions config) (allValues @FileType)
listExtensions :: CtHeadersConfig
-> FileType
-> [Text]
listExtensions config fileType =
hcFileExtensions (configByFileType config fileType)
configByFileType :: CtHeadersConfig
-> FileType
-> CtHeaderConfig
configByFileType HeadersConfig {..} fileType = case fileType of
C -> hscC
CPP -> hscCpp
CSS -> hscCss
Haskell -> hscHaskell
HTML -> hscHtml
Java -> hscJava
JS -> hscJs
PureScript -> hscPureScript
Rust -> hscRust
Scala -> hscScala
Shell -> hscShell