{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StrictData #-}
module Headroom.FileSupport.Types
(
FileSupport(..)
, SyntaxAnalysis(..)
, defaultFileSupport
, ExtractTemplateDataFn
, ExtractVariablesFn
)
where
import Headroom.Configuration.Types ( HeaderSyntax )
import Headroom.FileSupport.TemplateData ( TemplateData(..) )
import Headroom.FileType.Types ( FileType )
import Headroom.Header.Types ( HeaderTemplate )
import Headroom.SourceCode ( SourceCode )
import Headroom.Template ( Template )
import Headroom.Variables.Types ( Variables )
import RIO
data FileSupport = FileSupport
{ FileSupport -> SyntaxAnalysis
fsSyntaxAnalysis :: SyntaxAnalysis
, :: ExtractTemplateDataFn
, :: ExtractVariablesFn
, FileSupport -> FileType
fsFileType :: FileType
}
data SyntaxAnalysis = SyntaxAnalysis
{ :: Text -> Bool
, :: Text -> Bool
}
type
= forall a
. Template a
=> a
-> HeaderSyntax
-> TemplateData
type
= HeaderTemplate
-> Maybe (Int, Int)
-> SourceCode
-> Variables
defaultFileSupport :: FileType
-> SyntaxAnalysis
-> FileSupport
defaultFileSupport :: FileType -> SyntaxAnalysis -> FileSupport
defaultFileSupport FileType
fileType SyntaxAnalysis
syntaxAnalysis = FileSupport :: SyntaxAnalysis
-> (forall a. Template a => a -> HeaderSyntax -> TemplateData)
-> ExtractVariablesFn
-> FileType
-> FileSupport
FileSupport
{ fsSyntaxAnalysis :: SyntaxAnalysis
fsSyntaxAnalysis = SyntaxAnalysis
syntaxAnalysis
, fsExtractTemplateData :: forall a. Template a => a -> HeaderSyntax -> TemplateData
fsExtractTemplateData = (HeaderSyntax -> TemplateData) -> a -> HeaderSyntax -> TemplateData
forall a b. a -> b -> a
const ((HeaderSyntax -> TemplateData)
-> a -> HeaderSyntax -> TemplateData)
-> (TemplateData -> HeaderSyntax -> TemplateData)
-> TemplateData
-> a
-> HeaderSyntax
-> TemplateData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TemplateData -> HeaderSyntax -> TemplateData
forall a b. a -> b -> a
const (TemplateData -> a -> HeaderSyntax -> TemplateData)
-> TemplateData -> a -> HeaderSyntax -> TemplateData
forall a b. (a -> b) -> a -> b
$ TemplateData
NoTemplateData
, fsExtractVariables :: ExtractVariablesFn
fsExtractVariables = (Maybe (Int, Int) -> SourceCode -> Variables) -> ExtractVariablesFn
forall a b. a -> b -> a
const ((Maybe (Int, Int) -> SourceCode -> Variables)
-> ExtractVariablesFn)
-> (Variables -> Maybe (Int, Int) -> SourceCode -> Variables)
-> Variables
-> ExtractVariablesFn
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SourceCode -> Variables)
-> Maybe (Int, Int) -> SourceCode -> Variables
forall a b. a -> b -> a
const ((SourceCode -> Variables)
-> Maybe (Int, Int) -> SourceCode -> Variables)
-> (Variables -> SourceCode -> Variables)
-> Variables
-> Maybe (Int, Int)
-> SourceCode
-> Variables
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Variables -> SourceCode -> Variables
forall a b. a -> b -> a
const (Variables -> ExtractVariablesFn)
-> Variables -> ExtractVariablesFn
forall a b. (a -> b) -> a -> b
$ Variables
forall a. Monoid a => a
mempty
, fsFileType :: FileType
fsFileType = FileType
fileType
}