mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-18 17:57:11 +03:00
dev: lib: Utils cleanups
This commit is contained in:
parent
5bc977442a
commit
80249c3e8a
@ -1,22 +1,11 @@
|
||||
{-|
|
||||
|
||||
Standard imports and utilities which are useful everywhere, or needed low
|
||||
in the module hierarchy. This is the bottom of hledger's module graph.
|
||||
|
||||
Utilities used throughout hledger, or needed low in the module hierarchy.
|
||||
This is the bottom of hledger's module graph.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Hledger.Utils (---- provide these frequently used modules - or not, for clearer api:
|
||||
-- module Control.Monad,
|
||||
-- module Data.List,
|
||||
-- module Data.Maybe,
|
||||
-- module Data.Time.Calendar,
|
||||
-- module Data.Time.Clock,
|
||||
-- module Data.Time.LocalTime,
|
||||
-- module Data.Tree,
|
||||
-- module Text.RegexPR,
|
||||
-- module Text.Printf,
|
||||
---- all of this one:
|
||||
module Hledger.Utils (
|
||||
module Hledger.Utils,
|
||||
module Hledger.Utils.Debug,
|
||||
module Hledger.Utils.Parse,
|
||||
@ -25,9 +14,6 @@ module Hledger.Utils (---- provide these frequently used modules - or not, for c
|
||||
module Hledger.Utils.String,
|
||||
module Hledger.Utils.Text,
|
||||
module Hledger.Utils.Test,
|
||||
-- Debug.Trace.trace,
|
||||
-- module Data.PPrint,
|
||||
-- the rest need to be done in each module I think
|
||||
)
|
||||
where
|
||||
|
||||
@ -42,8 +28,8 @@ import qualified Data.Text.Lazy.Builder as TB
|
||||
import Data.Time.Clock (getCurrentTime)
|
||||
import Data.Time.LocalTime (LocalTime, ZonedTime, getCurrentTimeZone,
|
||||
utcToLocalTime, utcToZonedTime)
|
||||
import Data.Tree (foldTree, Tree (Node, subForest))
|
||||
import Language.Haskell.TH (DecsQ, Name, mkName, nameBase)
|
||||
-- import Language.Haskell.TH.Quote (QuasiQuoter(..))
|
||||
import Language.Haskell.TH.Syntax (Q, Exp)
|
||||
import Lens.Micro ((&), (.~))
|
||||
import Lens.Micro.TH (DefName(TopName), lensClass, lensField, makeLensesWith, classyRules)
|
||||
@ -61,7 +47,6 @@ import Hledger.Utils.Regex
|
||||
import Hledger.Utils.String
|
||||
import Hledger.Utils.Text
|
||||
import Hledger.Utils.Test
|
||||
import Data.Tree (foldTree, Tree (Node, subForest))
|
||||
|
||||
|
||||
-- tuples
|
||||
@ -128,8 +113,6 @@ treeLeaves :: Show a => Tree a -> [a]
|
||||
treeLeaves Node{subForest=[]} = []
|
||||
treeLeaves t = foldTree (\a bs -> (if null bs then (a:) else id) $ concat bs) t
|
||||
|
||||
-- text
|
||||
|
||||
-- time
|
||||
|
||||
getCurrentLocalTime :: IO LocalTime
|
||||
|
@ -108,12 +108,12 @@ colorOption =
|
||||
-- or (
|
||||
-- the program was not started with --color=no|never
|
||||
-- and a NO_COLOR environment variable is not defined
|
||||
-- and stdout supports ANSI color and -o/--output-file was not used or is "-"
|
||||
-- and stdout supports ANSI color
|
||||
-- and -o/--output-file was not used, or its value is "-"
|
||||
-- ).
|
||||
useColorOnStdout :: Bool
|
||||
useColorOnStdout = not hasOutputFile && useColorOnHandle stdout
|
||||
|
||||
-- Avoid using dbg*, pshow etc. in this function (infinite loop).
|
||||
-- | Like useColorOnStdout, but checks for ANSI color support on stderr,
|
||||
-- and is not affected by -o/--output-file.
|
||||
useColorOnStderr :: Bool
|
||||
|
Loading…
Reference in New Issue
Block a user