From 2aaab4b1b7cffbfb5d16f6f2adfb277607b006b3 Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Fri, 11 Sep 2020 16:51:56 +1000 Subject: [PATCH] lib: Make Default instances clearer, remove Default instance for Bool. --- hledger-lib/Hledger/Read/Common.hs | 12 +++++++++++- hledger-lib/Hledger/Utils.hs | 3 --- hledger/Hledger/Cli/CliOptions.hs | 23 ++++++++++++----------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 977d037b8..d19d09349 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -199,7 +199,17 @@ data InputOpts = InputOpts { instance Default InputOpts where def = definputopts definputopts :: InputOpts -definputopts = InputOpts def def def def def def True def def +definputopts = InputOpts + { mformat_ = Nothing + , mrules_file_ = Nothing + , aliases_ = [] + , anon_ = False + , ignore_assertions_ = False + , new_ = False + , new_save_ = True + , pivot_ = "" + , auto_ = False + } rawOptsToInputOpts :: RawOpts -> InputOpts rawOptsToInputOpts rawopts = InputOpts{ diff --git a/hledger-lib/Hledger/Utils.hs b/hledger-lib/Hledger/Utils.hs index ab80eef87..e8f319926 100644 --- a/hledger-lib/Hledger/Utils.hs +++ b/hledger-lib/Hledger/Utils.hs @@ -36,7 +36,6 @@ where import Control.Monad (liftM, when) -- import Data.Char -import Data.Default import Data.FileEmbed (makeRelativeToProject, embedStringFile) import Data.List -- import Data.Maybe @@ -144,8 +143,6 @@ getCurrentZonedTime = do -- misc -instance Default Bool where def = False - -- | Apply a function the specified number of times, -- which should be > 0 (otherwise does nothing). -- Possibly uses O(n) stack ? diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index e034ac693..a9809f61d 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -415,17 +415,18 @@ instance Default CliOpts where def = defcliopts defcliopts :: CliOpts defcliopts = CliOpts - def - def - def - def - def - def - def - def - def - def - defaultWidth + { rawopts_ = def + , command_ = "" + , file_ = [] + , inputopts_ = def + , reportopts_ = def + , output_file_ = Nothing + , output_format_ = Nothing + , debug_ = 0 + , no_new_accounts_ = False + , width_ = Nothing + , available_width_ = defaultWidth + } -- | Default width for hledger console output, when not otherwise specified. defaultWidth :: Int