{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE DeriveDataTypeable #-}
module Language.Haskell.Brittany.Internal.Config.Types
( module Language.Haskell.Brittany.Internal.Config.Types
, cMap
)
where
#include "prelude.inc"
import Data.Yaml
import qualified Data.Aeson.Types as Aeson
import GHC.Generics
import Data.Data ( Data )
import Data.Coerce ( Coercible, coerce )
import Data.Semigroup.Generic
import Data.Semigroup ( Last, Option )
import Data.CZipWith
confUnpack :: Coercible a b => Identity a -> b
confUnpack (Identity x) = coerce x
data CDebugConfig f = DebugConfig
{ _dconf_dump_config :: f (Semigroup.Last Bool)
, _dconf_dump_annotations :: f (Semigroup.Last Bool)
, _dconf_dump_ast_unknown :: f (Semigroup.Last Bool)
, _dconf_dump_ast_full :: f (Semigroup.Last Bool)
, _dconf_dump_bridoc_raw :: f (Semigroup.Last Bool)
, _dconf_dump_bridoc_simpl_alt :: f (Semigroup.Last Bool)
, _dconf_dump_bridoc_simpl_floating :: f (Semigroup.Last Bool)
, _dconf_dump_bridoc_simpl_par :: f (Semigroup.Last Bool)
, _dconf_dump_bridoc_simpl_columns :: f (Semigroup.Last Bool)
, _dconf_dump_bridoc_simpl_indent :: f (Semigroup.Last Bool)
, _dconf_dump_bridoc_final :: f (Semigroup.Last Bool)
, _dconf_roundtrip_exactprint_only :: f (Semigroup.Last Bool)
}
deriving (Generic)
data CLayoutConfig f = LayoutConfig
{ _lconfig_cols :: f (Last Int)
, _lconfig_indentPolicy :: f (Last IndentPolicy)
, _lconfig_indentAmount :: f (Last Int)
, _lconfig_indentWhereSpecial :: f (Last Bool)
, _lconfig_indentListSpecial :: f (Last Bool)
, _lconfig_importColumn :: f (Last Int)
, _lconfig_importAsColumn :: f (Last Int)
, _lconfig_altChooser :: f (Last AltChooser)
, _lconfig_columnAlignMode :: f (Last ColumnAlignMode)
, _lconfig_alignmentLimit :: f (Last Int)
, _lconfig_alignmentBreakOnMultiline :: f (Last Bool)
, _lconfig_hangingTypeSignature :: f (Last Bool)
, _lconfig_reformatModulePreamble :: f (Last Bool)
, _lconfig_allowSingleLineExportList :: f (Last Bool)
, _lconfig_allowHangingQuasiQuotes :: f (Last Bool)
, _lconfig_experimentalSemicolonNewlines :: f (Last Bool)
}
deriving (Generic)
data CForwardOptions f = ForwardOptions
{ _options_ghc :: f [String]
}
deriving (Generic)
data CErrorHandlingConfig f = ErrorHandlingConfig
{ _econf_produceOutputOnErrors :: f (Semigroup.Last Bool)
, _econf_Werror :: f (Semigroup.Last Bool)
, _econf_ExactPrintFallback :: f (Semigroup.Last ExactPrintFallbackMode)
, _econf_omit_output_valid_check :: f (Semigroup.Last Bool)
}
deriving (Generic)
data CPreProcessorConfig f = PreProcessorConfig
{ _ppconf_CPPMode :: f (Semigroup.Last CPPMode)
, _ppconf_hackAroundIncludes :: f (Semigroup.Last Bool)
}
deriving (Generic)
data CConfig f = Config
{ _conf_version :: f (Semigroup.Last Int)
, _conf_debug :: CDebugConfig f
, _conf_layout :: CLayoutConfig f
, _conf_errorHandling :: CErrorHandlingConfig f
, _conf_forward :: CForwardOptions f
, _conf_preprocessor :: CPreProcessorConfig f
, _conf_roundtrip_exactprint_only :: f (Semigroup.Last Bool)
, _conf_obfuscate :: f (Semigroup.Last Bool)
}
deriving (Generic)
type DebugConfig = CDebugConfig Identity
type LayoutConfig = CLayoutConfig Identity
type ForwardOptions = CForwardOptions Identity
type ErrorHandlingConfig = CErrorHandlingConfig Identity
type Config = CConfig Identity
deriving instance Show (CDebugConfig Identity)
deriving instance Show (CLayoutConfig Identity)
deriving instance Show (CErrorHandlingConfig Identity)
deriving instance Show (CForwardOptions Identity)
deriving instance Show (CPreProcessorConfig Identity)
deriving instance Show (CConfig Identity)
deriving instance Show (CDebugConfig Option)
deriving instance Show (CLayoutConfig Option)
deriving instance Show (CErrorHandlingConfig Option)
deriving instance Show (CForwardOptions Option)
deriving instance Show (CPreProcessorConfig Option)
deriving instance Show (CConfig Option)
deriving instance Data (CDebugConfig Identity)
deriving instance Data (CLayoutConfig Identity)
deriving instance Data (CErrorHandlingConfig Identity)
deriving instance Data (CForwardOptions Identity)
deriving instance Data (CPreProcessorConfig Identity)
deriving instance Data (CConfig Identity)
#if MIN_VERSION_ghc(8,2,0)
deriving instance Data (CDebugConfig Option)
deriving instance Data (CLayoutConfig Option)
deriving instance Data (CErrorHandlingConfig Option)
deriving instance Data (CForwardOptions Option)
deriving instance Data (CPreProcessorConfig Option)
deriving instance Data (CConfig Option)
#endif
instance Semigroup.Semigroup (CDebugConfig Option) where
(<>) = gmappend
instance Semigroup.Semigroup (CLayoutConfig Option) where
(<>) = gmappend
instance Semigroup.Semigroup (CErrorHandlingConfig Option) where
(<>) = gmappend
instance Semigroup.Semigroup (CForwardOptions Option) where
(<>) = gmappend
instance Semigroup.Semigroup (CPreProcessorConfig Option) where
(<>) = gmappend
instance Semigroup.Semigroup (CConfig Option) where
(<>) = gmappend
instance Semigroup.Semigroup (CDebugConfig Identity) where
(<>) = gmappend
instance Semigroup.Semigroup (CLayoutConfig Identity) where
(<>) = gmappend
instance Semigroup.Semigroup (CErrorHandlingConfig Identity) where
(<>) = gmappend
instance Semigroup.Semigroup (CForwardOptions Identity) where
(<>) = gmappend
instance Semigroup.Semigroup (CPreProcessorConfig Identity) where
(<>) = gmappend
instance Semigroup.Semigroup (CConfig Identity) where
(<>) = gmappend
instance Monoid (CDebugConfig Option) where
mempty = gmempty
mappend = gmappend
instance Monoid (CLayoutConfig Option) where
mempty = gmempty
mappend = gmappend
instance Monoid (CErrorHandlingConfig Option) where
mempty = gmempty
mappend = gmappend
instance Monoid (CForwardOptions Option) where
mempty = gmempty
mappend = gmappend
instance Monoid (CPreProcessorConfig Option) where
mempty = gmempty
mappend = gmappend
instance Monoid (CConfig Option) where
mempty = gmempty
mappend = gmappend
data IndentPolicy = IndentPolicyLeft
| IndentPolicyFree
| IndentPolicyMultiple
deriving (Eq, Show, Generic, Data)
data AltChooser = AltChooserSimpleQuick
| AltChooserShallowBest
| AltChooserBoundedSearch Int
deriving (Show, Generic, Data)
data ColumnAlignMode
= ColumnAlignModeDisabled
| ColumnAlignModeUnanimously
| ColumnAlignModeMajority Float
| ColumnAlignModeAnimouslyScale Int
| ColumnAlignModeAnimously
| ColumnAlignModeAlways
deriving (Show, Generic, Data)
data CPPMode = CPPModeAbort
| CPPModeWarn
| CPPModeNowarn
deriving (Show, Generic, Data)
data ExactPrintFallbackMode
= ExactPrintFallbackModeNever
| ExactPrintFallbackModeInline
| ExactPrintFallbackModeRisky
deriving (Show, Generic, Data)
instance CFunctor CDebugConfig
instance CFunctor CLayoutConfig
instance CFunctor CErrorHandlingConfig
instance CFunctor CForwardOptions
instance CFunctor CPreProcessorConfig
instance CFunctor CConfig
deriveCZipWith ''CDebugConfig
deriveCZipWith ''CLayoutConfig
deriveCZipWith ''CErrorHandlingConfig
deriveCZipWith ''CForwardOptions
deriveCZipWith ''CPreProcessorConfig
deriveCZipWith ''CConfig