hledger-lib-1.3: Core data types, parsers and functionality for the hledger accounting tools

Safe Haskell | None
Language | Haskell2010

Hledger.Utils

Description

Standard imports and utilities which are useful everywhere, or needed low in the module hierarchy. This is the bottom of hledger's module graph.

Synopsis

- first3 :: (t2, t1, t) -> t2
- second3 :: (t1, t2, t) -> t2
- third3 :: (t1, t, t2) -> t2
- first4 :: (t3, t2, t1, t) -> t3
- second4 :: (t2, t3, t1, t) -> t3
- third4 :: (t2, t1, t3, t) -> t3
- fourth4 :: (t2, t1, t, t3) -> t3
- first5 :: (t4, t3, t2, t1, t) -> t4
- second5 :: (t3, t4, t2, t1, t) -> t4
- third5 :: (t3, t2, t4, t1, t) -> t4
- fourth5 :: (t3, t2, t1, t4, t) -> t4
- fifth5 :: (t3, t2, t1, t, t4) -> t4
- first6 :: (t5, t4, t3, t2, t1, t) -> t5
- second6 :: (t4, t5, t3, t2, t1, t) -> t5
- third6 :: (t4, t3, t5, t2, t1, t) -> t5
- fourth6 :: (t4, t3, t2, t5, t1, t) -> t5
- fifth6 :: (t4, t3, t2, t1, t5, t) -> t5
- sixth6 :: (t4, t3, t2, t1, t, t5) -> t5
- splitAtElement :: Eq a => a -> [a] -> [[a]]
- getCurrentLocalTime :: IO LocalTime
- getCurrentZonedTime :: IO ZonedTime
- isLeft :: Either a b -> Bool
- isRight :: Either a b -> Bool
- applyN :: Int -> (a -> a) -> a -> a
- expandPath :: FilePath -> FilePath -> IO FilePath
- firstJust :: Eq a => [Maybe a] -> Maybe a
- readFile' :: FilePath -> IO Text
- readFileAnyLineEnding :: FilePath -> IO Text
- readFileOrStdinAnyLineEnding :: String -> IO Text
- maximum' :: Integral a => [a] -> a
- sumStrict :: Num a => [a] -> a
- maximumStrict :: Ord a => [a] -> a
- minimumStrict :: Ord a => [a] -> a
- sequence' :: Monad f => [f a] -> f [a]
- mapM' :: Monad f => (a -> f b) -> [a] -> f [b]
- module Hledger.Utils.Debug
- module Hledger.Utils.Parse
- module Hledger.Utils.Regex
- module Hledger.Utils.String
- module Hledger.Utils.Text
- module Hledger.Utils.Test
- module Hledger.Utils.Color
- module Hledger.Utils.Tree
- type SystemString = String
- fromSystemString :: SystemString -> String
- toSystemString :: String -> SystemString
- error' :: String -> a
- userError' :: String -> IOError
- usageError :: String -> a

# Documentation

first3 :: (t2, t1, t) -> t2 #

second3 :: (t1, t2, t) -> t2 #

third3 :: (t1, t, t2) -> t2 #

first4 :: (t3, t2, t1, t) -> t3 #

second4 :: (t2, t3, t1, t) -> t3 #

third4 :: (t2, t1, t3, t) -> t3 #

fourth4 :: (t2, t1, t, t3) -> t3 #

first5 :: (t4, t3, t2, t1, t) -> t4 #

second5 :: (t3, t4, t2, t1, t) -> t4 #

third5 :: (t3, t2, t4, t1, t) -> t4 #

fourth5 :: (t3, t2, t1, t4, t) -> t4 #

fifth5 :: (t3, t2, t1, t, t4) -> t4 #

first6 :: (t5, t4, t3, t2, t1, t) -> t5 #

second6 :: (t4, t5, t3, t2, t1, t) -> t5 #

third6 :: (t4, t3, t5, t2, t1, t) -> t5 #

fourth6 :: (t4, t3, t2, t5, t1, t) -> t5 #

fifth6 :: (t4, t3, t2, t1, t5, t) -> t5 #

sixth6 :: (t4, t3, t2, t1, t, t5) -> t5 #

splitAtElement :: Eq a => a -> [a] -> [[a]] #

getCurrentLocalTime :: IO LocalTime #

getCurrentZonedTime :: IO ZonedTime #

isLeft :: Either a b -> Bool #

isRight :: Either a b -> Bool #

applyN :: Int -> (a -> a) -> a -> a #

Apply a function the specified number of times. Possibly uses O(n) stack ?

expandPath :: FilePath -> FilePath -> IO FilePath #

Convert a possibly relative, possibly tilde-containing file path to an absolute one, given the current directory. ~username is not supported. Leave "-" unchanged. Can raise an error.

firstJust :: Eq a => [Maybe a] -> Maybe a #

readFile' :: FilePath -> IO Text #

Read a file in universal newline mode, handling any of the usual line ending conventions.

readFileAnyLineEnding :: FilePath -> IO Text #

Read a file in universal newline mode, handling any of the usual line ending conventions.

readFileOrStdinAnyLineEnding :: String -> IO Text #

Read the given file, or standard input if the path is "-", using universal newline mode.

maximum' :: Integral a => [a] -> a #

Total version of maximum, for integral types, giving 0 for an empty list.

sumStrict :: Num a => [a] -> a #

Strict version of sum that doesn’t leak space

maximumStrict :: Ord a => [a] -> a #

Strict version of maximum that doesn’t leak space

minimumStrict :: Ord a => [a] -> a #

Strict version of minimum that doesn’t leak space

sequence' :: Monad f => [f a] -> f [a] #

This is a version of sequence based on difference lists. It is slightly faster but we mostly use it because it uses the heap instead of the stack. This has the advantage that Neil Mitchell’s trick of limiting the stack size to discover space leaks doesn’t show this as a false positive.

mapM' :: Monad f => (a -> f b) -> [a] -> f [b] #

module Hledger.Utils.Debug

module Hledger.Utils.Parse

module Hledger.Utils.Regex

module Hledger.Utils.String

module Hledger.Utils.Text

module Hledger.Utils.Test

module Hledger.Utils.Color

module Hledger.Utils.Tree

type SystemString = String #

A string received from or being passed to the operating system, such as a file path, command-line argument, or environment variable name or value. With GHC versions before 7.2 on some platforms (posix) these are typically encoded. When converting, we assume the encoding is UTF-8 (cf http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html#UTF8).

fromSystemString :: SystemString -> String #

Convert a system string to an ordinary string, decoding from UTF-8 if it appears to be UTF8-encoded and GHC version is less than 7.2.

toSystemString :: String -> SystemString #

Convert a unicode string to a system string, encoding with UTF-8 if we are on a posix platform with GHC < 7.2.

error' :: String -> a #

A SystemString-aware version of error.

userError' :: String -> IOError #

A SystemString-aware version of userError.

usageError :: String -> a #

A SystemString-aware version of error that adds a usage hint.