Add sub-config-alternative default to lib interface
i.e. `forwardOptionsSyntaxExtsEnabled`pull/35/head
parent
0251062100
commit
5a82968a7b
|
@ -19,6 +19,7 @@ import Data.List ( groupBy )
|
||||||
import Language.Haskell.Brittany.Internal
|
import Language.Haskell.Brittany.Internal
|
||||||
|
|
||||||
import Language.Haskell.Brittany.Internal.Config.Types
|
import Language.Haskell.Brittany.Internal.Config.Types
|
||||||
|
import Language.Haskell.Brittany.Internal.Config
|
||||||
|
|
||||||
import Data.Coerce ( coerce )
|
import Data.Coerce ( coerce )
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import NeatInterpolation
|
||||||
import Language.Haskell.Brittany.Internal
|
import Language.Haskell.Brittany.Internal
|
||||||
|
|
||||||
import Language.Haskell.Brittany.Internal.Config.Types
|
import Language.Haskell.Brittany.Internal.Config.Types
|
||||||
|
import Language.Haskell.Brittany.Internal.Config
|
||||||
|
|
||||||
import System.Timeout ( timeout )
|
import System.Timeout ( timeout )
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
module Language.Haskell.Brittany
|
module Language.Haskell.Brittany
|
||||||
( parsePrintModule
|
( parsePrintModule
|
||||||
, staticDefaultConfig
|
, staticDefaultConfig
|
||||||
|
, forwardOptionsSyntaxExtsEnabled
|
||||||
, Config
|
, Config
|
||||||
, CConfig(..)
|
, CConfig(..)
|
||||||
, CDebugConfig(..)
|
, CDebugConfig(..)
|
||||||
|
@ -21,4 +22,5 @@ where
|
||||||
import Language.Haskell.Brittany.Internal
|
import Language.Haskell.Brittany.Internal
|
||||||
import Language.Haskell.Brittany.Internal.Types
|
import Language.Haskell.Brittany.Internal.Types
|
||||||
import Language.Haskell.Brittany.Internal.Config.Types
|
import Language.Haskell.Brittany.Internal.Config.Types
|
||||||
|
import Language.Haskell.Brittany.Internal.Config
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import qualified Data.Text.Lazy.Builder as Text.Builder
|
||||||
|
|
||||||
import Language.Haskell.Brittany.Internal.Types
|
import Language.Haskell.Brittany.Internal.Types
|
||||||
import Language.Haskell.Brittany.Internal.Config.Types
|
import Language.Haskell.Brittany.Internal.Config.Types
|
||||||
|
import Language.Haskell.Brittany.Internal.Config
|
||||||
import Language.Haskell.Brittany.Internal.LayouterBasics
|
import Language.Haskell.Brittany.Internal.LayouterBasics
|
||||||
|
|
||||||
import Language.Haskell.Brittany.Internal.Layouters.Type
|
import Language.Haskell.Brittany.Internal.Layouters.Type
|
||||||
|
|
|
@ -7,6 +7,7 @@ module Language.Haskell.Brittany.Internal.Config
|
||||||
, Config
|
, Config
|
||||||
, configParser
|
, configParser
|
||||||
, staticDefaultConfig
|
, staticDefaultConfig
|
||||||
|
, forwardOptionsSyntaxExtsEnabled
|
||||||
, readMergePersConfig
|
, readMergePersConfig
|
||||||
, showConfigYaml
|
, showConfigYaml
|
||||||
)
|
)
|
||||||
|
@ -32,6 +33,68 @@ import Data.Coerce ( Coercible, coerce )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
staticDefaultConfig :: Config
|
||||||
|
staticDefaultConfig = Config
|
||||||
|
{ _conf_version = coerce (1 :: Int)
|
||||||
|
, _conf_debug = DebugConfig
|
||||||
|
{ _dconf_dump_config = coerce False
|
||||||
|
, _dconf_dump_annotations = coerce False
|
||||||
|
, _dconf_dump_ast_unknown = coerce False
|
||||||
|
, _dconf_dump_ast_full = coerce False
|
||||||
|
, _dconf_dump_bridoc_raw = coerce False
|
||||||
|
, _dconf_dump_bridoc_simpl_alt = coerce False
|
||||||
|
, _dconf_dump_bridoc_simpl_floating = coerce False
|
||||||
|
, _dconf_dump_bridoc_simpl_par = coerce False
|
||||||
|
, _dconf_dump_bridoc_simpl_columns = coerce False
|
||||||
|
, _dconf_dump_bridoc_simpl_indent = coerce False
|
||||||
|
, _dconf_dump_bridoc_final = coerce False
|
||||||
|
, _dconf_roundtrip_exactprint_only = coerce False
|
||||||
|
}
|
||||||
|
, _conf_layout = LayoutConfig
|
||||||
|
{ _lconfig_cols = coerce (80 :: Int)
|
||||||
|
, _lconfig_indentPolicy = coerce IndentPolicyFree
|
||||||
|
, _lconfig_indentAmount = coerce (2 :: Int)
|
||||||
|
, _lconfig_indentWhereSpecial = coerce True
|
||||||
|
, _lconfig_indentListSpecial = coerce True
|
||||||
|
, _lconfig_importColumn = coerce (60 :: Int)
|
||||||
|
, _lconfig_altChooser = coerce (AltChooserBoundedSearch 3)
|
||||||
|
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
||||||
|
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
||||||
|
, _lconfig_alignmentBreakOnMultiline = coerce True
|
||||||
|
}
|
||||||
|
, _conf_errorHandling = ErrorHandlingConfig
|
||||||
|
{ _econf_produceOutputOnErrors = coerce False
|
||||||
|
, _econf_Werror = coerce False
|
||||||
|
, _econf_ExactPrintFallback = coerce ExactPrintFallbackModeInline
|
||||||
|
, _econf_omit_output_valid_check = coerce False
|
||||||
|
}
|
||||||
|
, _conf_preprocessor = PreProcessorConfig
|
||||||
|
{ _ppconf_CPPMode = coerce CPPModeAbort
|
||||||
|
, _ppconf_hackAroundIncludes = coerce False
|
||||||
|
}
|
||||||
|
, _conf_forward = ForwardOptions
|
||||||
|
{ _options_ghc = Identity []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forwardOptionsSyntaxExtsEnabled :: ForwardOptions
|
||||||
|
forwardOptionsSyntaxExtsEnabled = ForwardOptions
|
||||||
|
{ _options_ghc = Identity
|
||||||
|
[ "-XLambdaCase"
|
||||||
|
, "-XMultiWayIf"
|
||||||
|
, "-XGADTs"
|
||||||
|
, "-XPatternGuards"
|
||||||
|
, "-XViewPatterns"
|
||||||
|
, "-XTupleSections"
|
||||||
|
, "-XExplicitForAll"
|
||||||
|
, "-XImplicitParams"
|
||||||
|
, "-XQuasiQuotes"
|
||||||
|
, "-XTemplateHaskell"
|
||||||
|
, "-XBangPatterns"
|
||||||
|
, "-XTypeApplications"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
configParser :: CmdParser Identity out (CConfig Option)
|
configParser :: CmdParser Identity out (CConfig Option)
|
||||||
configParser = do
|
configParser = do
|
||||||
-- TODO: why does the default not trigger; ind never should be []!!
|
-- TODO: why does the default not trigger; ind never should be []!!
|
||||||
|
@ -162,3 +225,4 @@ showConfigYaml :: Config -> String
|
||||||
showConfigYaml = Data.ByteString.Char8.unpack
|
showConfigYaml = Data.ByteString.Char8.unpack
|
||||||
. Data.Yaml.encode
|
. Data.Yaml.encode
|
||||||
. cMap (\(Identity x) -> Just x)
|
. cMap (\(Identity x) -> Just x)
|
||||||
|
|
||||||
|
|
|
@ -317,50 +317,6 @@ data ExactPrintFallbackMode
|
||||||
-- A PROGRAM BY TRANSFORMING IT.
|
-- A PROGRAM BY TRANSFORMING IT.
|
||||||
deriving (Show, Generic, Data)
|
deriving (Show, Generic, Data)
|
||||||
|
|
||||||
staticDefaultConfig :: Config
|
|
||||||
staticDefaultConfig = Config
|
|
||||||
{ _conf_version = coerce (1 :: Int)
|
|
||||||
, _conf_debug = DebugConfig
|
|
||||||
{ _dconf_dump_config = coerce False
|
|
||||||
, _dconf_dump_annotations = coerce False
|
|
||||||
, _dconf_dump_ast_unknown = coerce False
|
|
||||||
, _dconf_dump_ast_full = coerce False
|
|
||||||
, _dconf_dump_bridoc_raw = coerce False
|
|
||||||
, _dconf_dump_bridoc_simpl_alt = coerce False
|
|
||||||
, _dconf_dump_bridoc_simpl_floating = coerce False
|
|
||||||
, _dconf_dump_bridoc_simpl_par = coerce False
|
|
||||||
, _dconf_dump_bridoc_simpl_columns = coerce False
|
|
||||||
, _dconf_dump_bridoc_simpl_indent = coerce False
|
|
||||||
, _dconf_dump_bridoc_final = coerce False
|
|
||||||
, _dconf_roundtrip_exactprint_only = coerce False
|
|
||||||
}
|
|
||||||
, _conf_layout = LayoutConfig
|
|
||||||
{ _lconfig_cols = coerce (80 :: Int)
|
|
||||||
, _lconfig_indentPolicy = coerce IndentPolicyFree
|
|
||||||
, _lconfig_indentAmount = coerce (2 :: Int)
|
|
||||||
, _lconfig_indentWhereSpecial = coerce True
|
|
||||||
, _lconfig_indentListSpecial = coerce True
|
|
||||||
, _lconfig_importColumn = coerce (60 :: Int)
|
|
||||||
, _lconfig_altChooser = coerce (AltChooserBoundedSearch 3)
|
|
||||||
, _lconfig_columnAlignMode = coerce (ColumnAlignModeMajority 0.7)
|
|
||||||
, _lconfig_alignmentLimit = coerce (30 :: Int)
|
|
||||||
, _lconfig_alignmentBreakOnMultiline = coerce True
|
|
||||||
}
|
|
||||||
, _conf_errorHandling = ErrorHandlingConfig
|
|
||||||
{ _econf_produceOutputOnErrors = coerce False
|
|
||||||
, _econf_Werror = coerce False
|
|
||||||
, _econf_ExactPrintFallback = coerce ExactPrintFallbackModeInline
|
|
||||||
, _econf_omit_output_valid_check = coerce False
|
|
||||||
}
|
|
||||||
, _conf_preprocessor = PreProcessorConfig
|
|
||||||
{ _ppconf_CPPMode = coerce CPPModeAbort
|
|
||||||
, _ppconf_hackAroundIncludes = coerce False
|
|
||||||
}
|
|
||||||
, _conf_forward = ForwardOptions
|
|
||||||
{ _options_ghc = Identity []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cMap :: CZipWith k => (forall a . f a -> g a) -> k f -> k g
|
cMap :: CZipWith k => (forall a . f a -> g a) -> k f -> k g
|
||||||
cMap f c = cZipWith (\_ -> f) c c
|
cMap f c = cZipWith (\_ -> f) c c
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue