hledger-1.52.1: Command-line interface for the hledger accounting system

Safe Haskell | None
Language | GHC2021

Hledger.Cli.Script

Description

A convenient module to import in hledger scripts, aiming to provide the most useful imports and reduce boilerplate. |

Synopsis

- module Control.Applicative
- module Control.Concurrent
- module Control.Monad
- module Data.Char
- module Data.Either
- module Data.List
- module Data.Maybe
- module Data.Ord
- module Data.Time
- module Hledger
- module Hledger.Cli.CliOptions
- module Hledger.Cli.Commands
- module Hledger.Cli.CompoundBalanceCommand
- module Hledger.Cli.DocFiles
- module Hledger.Cli.Utils
- module Hledger.Cli.Version
- module System.Console.CmdArgs.Explicit
- module System.Directory
- module System.Environment
- module System.Exit
- module System.IO
- module System.IO.Error
- module System.Process
- data Text
- ($>) :: Functor f => f a -> b -> f b
- formatRealFloat :: RealFloat a => a -> FieldFormatter
- (<&>) :: Functor f => f a -> (a -> b) -> f b
- type ModifierParser = String -> FormatParse
- type FieldFormatter = FieldFormat -> ShowS
- data FormatParse = FormatParse {
  - fpModifiers :: String
  - fpChar :: Char
  - fpRest :: String
  }
- data FieldFormat = FieldFormat {
  - fmtWidth :: Maybe Int
  - fmtPrecision :: Maybe Int
  - fmtAdjust :: Maybe FormatAdjustment
  - fmtSign :: Maybe FormatSign
  - fmtAlternate :: Bool
  - fmtModifiers :: String
  - fmtChar :: Char
  }
- data FormatSign
  - = SignPlus
  - | SignSpace
- data FormatAdjustment
  - = LeftAdjust
  - | ZeroPad
- class IsChar c where
  - toChar :: c -> Char
  - fromChar :: Char -> c
- class PrintfArg a where
  - formatArg :: a -> FieldFormatter
  - parseFormat :: a -> ModifierParser
- class HPrintfType t
- class PrintfType t
- printf :: PrintfType r => String -> r
- hPrintf :: HPrintfType r => Handle -> String -> r
- vFmt :: Char -> FieldFormat -> FieldFormat
- formatChar :: Char -> FieldFormatter
- formatInt :: (Integral a, Bounded a) => a -> FieldFormatter
- formatInteger :: Integer -> FieldFormatter
- perror :: String -> a
- errorBadFormat :: Char -> a
- errorShortFormat :: a
- errorMissingArgument :: a
- errorBadArgument :: a
- pack :: String -> Text
- unpack :: Text -> String
- searchPathSeparator :: Char
- normalise :: FilePath -> FilePath
- dropTrailingPathSeparator :: FilePath -> FilePath
- makeRelative :: FilePath -> FilePath -> FilePath
- (</>) :: FilePath -> FilePath -> FilePath
- headDef :: a -> [a] -> a
- lastDef :: a -> [a] -> a
- pathSeparator :: Char
- pathSeparators :: [Char]
- isPathSeparator :: Char -> Bool
- isSearchPathSeparator :: Char -> Bool
- extSeparator :: Char
- isExtSeparator :: Char -> Bool
- splitSearchPath :: String -> [FilePath]
- getSearchPath :: IO [FilePath]
- splitExtension :: FilePath -> (String, String)
- takeExtension :: FilePath -> String
- (-<.>) :: FilePath -> String -> FilePath
- replaceExtension :: FilePath -> String -> FilePath
- (<.>) :: FilePath -> String -> FilePath
- dropExtension :: FilePath -> FilePath
- addExtension :: FilePath -> String -> FilePath
- hasExtension :: FilePath -> Bool
- isExtensionOf :: String -> FilePath -> Bool
- stripExtension :: String -> FilePath -> Maybe FilePath
- splitExtensions :: FilePath -> (FilePath, String)
- dropExtensions :: FilePath -> FilePath
- takeExtensions :: FilePath -> String
- replaceExtensions :: FilePath -> String -> FilePath
- splitDrive :: FilePath -> (FilePath, FilePath)
- joinDrive :: FilePath -> FilePath -> FilePath
- takeDrive :: FilePath -> FilePath
- dropDrive :: FilePath -> FilePath
- hasDrive :: FilePath -> Bool
- isDrive :: FilePath -> Bool
- splitFileName :: FilePath -> (String, String)
- replaceFileName :: FilePath -> String -> FilePath
- dropFileName :: FilePath -> FilePath
- takeFileName :: FilePath -> FilePath
- takeBaseName :: FilePath -> String
- replaceBaseName :: FilePath -> String -> FilePath
- hasTrailingPathSeparator :: FilePath -> Bool
- addTrailingPathSeparator :: FilePath -> FilePath
- takeDirectory :: FilePath -> FilePath
- replaceDirectory :: FilePath -> String -> FilePath
- combine :: FilePath -> FilePath -> FilePath
- splitPath :: FilePath -> [FilePath]
- splitDirectories :: FilePath -> [FilePath]
- joinPath :: [FilePath] -> FilePath
- equalFilePath :: FilePath -> FilePath -> Bool
- isValid :: FilePath -> Bool
- makeValid :: FilePath -> FilePath
- isRelative :: FilePath -> Bool
- isAbsolute :: FilePath -> Bool
- foldl1May :: (a -> a -> a) -> [a] -> Maybe a
- foldr1May :: (a -> a -> a) -> [a] -> Maybe a
- foldl1Note :: Partial => String -> (a -> a -> a) -> [a] -> a
- foldr1Note :: Partial => String -> (a -> a -> a) -> [a] -> a
- minimumMay :: Ord a => [a] -> Maybe a
- maximumMay :: Ord a => [a] -> Maybe a
- minimumNote :: (Partial, Ord a) => String -> [a] -> a
- maximumNote :: (Partial, Ord a) => String -> [a] -> a
- minimumByMay :: (a -> a -> Ordering) -> [a] -> Maybe a
- maximumByMay :: (a -> a -> Ordering) -> [a] -> Maybe a
- minimumByNote :: Partial => String -> (a -> a -> Ordering) -> [a] -> a
- maximumByNote :: Partial => String -> (a -> a -> Ordering) -> [a] -> a
- maximumBoundBy :: a -> (a -> a -> Ordering) -> [a] -> a
- minimumBoundBy :: a -> (a -> a -> Ordering) -> [a] -> a
- maximumBound :: Ord a => a -> [a] -> a
- minimumBound :: Ord a => a -> [a] -> a
- maximumBounded :: (Ord a, Bounded a) => [a] -> a
- minimumBounded :: (Ord a, Bounded a) => [a] -> a
- findJust :: (a -> Bool) -> [a] -> a
- findJustDef :: a -> (a -> Bool) -> [a] -> a
- findJustNote :: Partial => String -> (a -> Bool) -> [a] -> a
- minimumDef :: Ord a => a -> [a] -> a
- maximumDef :: Ord a => a -> [a] -> a
- minimumByDef :: a -> (a -> a -> Ordering) -> [a] -> a
- maximumByDef :: a -> (a -> a -> Ordering) -> [a] -> a
- foldl1Def :: a -> (a -> a -> a) -> [a] -> a
- foldr1Def :: a -> (a -> a -> a) -> [a] -> a
- abort :: Partial => String -> a
- tailErr :: Partial => [a] -> [a]
- headErr :: Partial => [a] -> a
- tailMay :: [a] -> Maybe [a]
- tailDef :: [a] -> [a] -> [a]
- tailNote :: Partial => String -> [a] -> [a]
- tailSafe :: [a] -> [a]
- initMay :: [a] -> Maybe [a]
- initDef :: [a] -> [a] -> [a]
- initNote :: Partial => String -> [a] -> [a]
- initSafe :: [a] -> [a]
- headMay :: [a] -> Maybe a
- lastMay :: [a] -> Maybe a
- headNote :: Partial => String -> [a] -> a
- lastNote :: Partial => String -> [a] -> a
- foldl1May' :: (a -> a -> a) -> [a] -> Maybe a
- foldl1Note' :: Partial => String -> (a -> a -> a) -> [a] -> a
- scanr1May :: (a -> a -> a) -> [a] -> Maybe [a]
- scanl1May :: (a -> a -> a) -> [a] -> Maybe [a]
- scanr1Def :: [a] -> (a -> a -> a) -> [a] -> [a]
- scanl1Def :: [a] -> (a -> a -> a) -> [a] -> [a]
- scanr1Note :: Partial => String -> (a -> a -> a) -> [a] -> [a]
- scanl1Note :: Partial => String -> (a -> a -> a) -> [a] -> [a]
- cycleMay :: [a] -> Maybe [a]
- cycleDef :: [a] -> [a] -> [a]
- cycleNote :: Partial => String -> [a] -> [a]
- fromJustDef :: a -> Maybe a -> a
- fromJustNote :: Partial => String -> Maybe a -> a
- assertNote :: Partial => String -> Bool -> a -> a
- atMay :: [a] -> Int -> Maybe a
- atDef :: a -> [a] -> Int -> a
- atNote :: Partial => String -> [a] -> Int -> a
- readEitherSafe :: Read a => String -> Either String a
- readMay :: Read a => String -> Maybe a
- readDef :: Read a => a -> String -> a
- readNote :: (Partial, Read a) => String -> String -> a
- lookupJust :: (Eq a, Partial) => a -> [(a, b)] -> b
- lookupJustDef :: Eq a => b -> a -> [(a, b)] -> b
- lookupJustNote :: (Partial, Eq a) => String -> a -> [(a, b)] -> b
- elemIndexJust :: (Partial, Eq a) => a -> [a] -> Int
- elemIndexJustDef :: Eq a => Int -> a -> [a] -> Int
- elemIndexJustNote :: (Partial, Eq a) => String -> a -> [a] -> Int
- findIndexJust :: (a -> Bool) -> [a] -> Int
- findIndexJustDef :: Int -> (a -> Bool) -> [a] -> Int
- findIndexJustNote :: Partial => String -> (a -> Bool) -> [a] -> Int
- toEnumMay :: (Enum a, Bounded a) => Int -> Maybe a
- toEnumDef :: (Enum a, Bounded a) => a -> Int -> a
- toEnumNote :: (Partial, Enum a, Bounded a) => String -> Int -> a
- toEnumSafe :: (Enum a, Bounded a) => Int -> a
- succMay :: (Enum a, Eq a, Bounded a) => a -> Maybe a
- succDef :: (Enum a, Eq a, Bounded a) => a -> a -> a
- succNote :: (Partial, Enum a, Eq a, Bounded a) => String -> a -> a
- succSafe :: (Enum a, Eq a, Bounded a) => a -> a
- predMay :: (Enum a, Eq a, Bounded a) => a -> Maybe a
- predDef :: (Enum a, Eq a, Bounded a) => a -> a -> a
- predNote :: (Partial, Enum a, Eq a, Bounded a) => String -> a -> a
- predSafe :: (Enum a, Eq a, Bounded a) => a -> a
- indexMay :: Ix a => (a, a) -> a -> Maybe Int
- indexDef :: Ix a => Int -> (a, a) -> a -> Int
- indexNote :: (Partial, Ix a) => String -> (a, a) -> a -> Int
- foldl1Def' :: a -> (a -> a -> a) -> [a] -> a
- argsToCliOpts :: [String] -> [String] -> IO CliOpts

# Documentation

module Control.Applicative

module Control.Concurrent

module Control.Monad

module Data.Char

module Data.Either

module Data.List

module Data.Maybe

module Data.Ord

module Data.Time

module Hledger

module Hledger.Cli.CliOptions

module Hledger.Cli.Commands

module Hledger.Cli.CompoundBalanceCommand

module Hledger.Cli.DocFiles

module Hledger.Cli.Utils

module Hledger.Cli.Version

module System.Console.CmdArgs.Explicit

module System.Directory

module System.Environment

module System.Exit

module System.IO

module System.IO.Error

module System.Process

data Text Source #

A space efficient, packed, unboxed Unicode text type.

#### Instances

Instances details

ToJSON Text |
Instance details Defined in Data.Aeson.Types.ToJSON Methods toJSON :: Text -> Value Source # toEncoding :: Text -> Encoding Source # toJSONList :: [Text] -> Value Source # toEncodingList :: [Text] -> Encoding Source # omitField :: Text -> Bool Source #
ToJSONKey Text |
Instance details Defined in Data.Aeson.Types.ToJSON Methods toJSONKey :: ToJSONKeyFunction Text Source # toJSONKeyList :: ToJSONKeyFunction [Text] Source #
Chunk Text |

Instance details

Defined in Data.Attoparsec.Internal.Types

Associated Types

type ChunkElem Text |
Instance details Defined in Data.Attoparsec.Internal.Types type ChunkElem Text = Char

Methods

nullChunk :: Text -> Bool

pappendChunk :: State Text -> Text -> State Text

atBufferEnd :: Text -> State Text -> Pos

bufferElemAt :: Text -> Pos -> State Text -> Maybe (ChunkElem Text, Int)

chunkElemToChar :: Text -> ChunkElem Text -> Char

PrintfArg Text | Since: text-1.2.2.0
Instance details Defined in Data.Text Methods formatArg :: Text -> FieldFormatter Source # parseFormat :: Text -> ModifierParser Source #
Binary Text | Since: text-1.2.1.0
Instance details Defined in Data.Text Methods put :: Text -> Put Source # get :: Get Text Source # putList :: [Text] -> Put Source #
FoldCase Text |
Instance details Defined in Data.CaseInsensitive.Internal Methods foldCase :: Text -> Text foldCaseList :: [Text] -> [Text]
NFData Text |
Instance details Defined in Data.Text Methods rnf :: Text -> () Source #
Monoid Text |
Instance details Defined in Data.Text Methods mempty :: Text Source # mappend :: Text -> Text -> Text Source # mconcat :: [Text] -> Text Source #
Semigroup Text | Beware: `stimes` will crash if the given number does not fit into an `Int`. Since: text-1.2.2.0
Instance details Defined in Data.Text Methods (<>) :: Text -> Text -> Text Source # sconcat :: NonEmpty Text -> Text Source # stimes :: Integral b => b -> Text -> Text Source #

Data Text

This instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction.

This instance was created by copying the updated behavior of `Data.Set.``Set` and `Data.Map.``Map`. If you feel a mistake has been made, please feel free to submit improvements.

The original discussion is archived here: could we get a Data instance for Data.Text.Text?

The followup discussion that changed the behavior of `Set` and `Map` is archived here: Proposal: Allow gunfold for Data.Map, ...

Instance details

Defined in Data.Text

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Text -> c Text Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Text Source #

toConstr :: Text -> Constr Source #

dataTypeOf :: Text -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Text) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Text) Source #

gmapT :: (forall b. Data b => b -> b) -> Text -> Text Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Text -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Text -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Text -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Text -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Text -> m Text Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Text -> m Text Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Text -> m Text Source #

IsString Text

Performs replacement on invalid scalar values:

    >>> :set -XOverloadedStrings
    >>> "\55555" :: Text
    "\65533"

Instance details Defined in Data.Text Methods fromString :: String -> Text Source #

IsList Text

Performs replacement on invalid scalar values:

    >>> :set -XOverloadedLists
    >>> ['\55555'] :: Text
    "\65533"

Since: text-1.2.0.0

Instance details

Defined in Data.Text

Associated Types

type Item Text |
Instance details Defined in Data.Text type Item Text = Char

Methods

fromList :: [Item Text] -> Text Source #

fromListN :: Int -> [Item Text] -> Text Source #

toList :: Text -> [Item Text] Source #

Read Text |
Instance details Defined in Data.Text Methods readsPrec :: Int -> ReadS Text Source # readList :: ReadS [Text] Source # readPrec :: ReadPrec Text Source # readListPrec :: ReadPrec [Text] Source #
Show CsvRules |
Instance details Defined in Hledger.Read.RulesReader Methods showsPrec :: Int -> CsvRules -> ShowS Source # show :: CsvRules -> String Source # showList :: [CsvRules] -> ShowS Source #
Show Text |
Instance details Defined in Data.Text.Show Methods showsPrec :: Int -> Text -> ShowS Source # show :: Text -> String Source # showList :: [Text] -> ShowS Source #
Eq CsvRules |
Instance details Defined in Hledger.Read.RulesReader Methods (==) :: CsvRules -> CsvRules -> Bool Source # (/=) :: CsvRules -> CsvRules -> Bool Source #
Eq Text |
Instance details Defined in Data.Text Methods (==) :: Text -> Text -> Bool Source # (/=) :: Text -> Text -> Bool Source #
Ord Text |
Instance details Defined in Data.Text Methods compare :: Text -> Text -> Ordering Source # (<) :: Text -> Text -> Bool Source # (<=) :: Text -> Text -> Bool Source # (>) :: Text -> Text -> Bool Source # (>=) :: Text -> Text -> Bool Source # max :: Text -> Text -> Text Source # min :: Text -> Text -> Text Source #
Hashable Text |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Text -> Int Source # hash :: Text -> Int Source #
Anon Text Source # |
Instance details Defined in Hledger.Cli.Anon Methods anon :: Text -> Text Source #
HasAmounts AccountTransactionsReportItem |
Instance details Defined in Hledger.Reports.AccountTransactionsReport Methods styleAmounts :: Map CommoditySymbol AmountStyle -> AccountTransactionsReportItem -> AccountTransactionsReportItem Source #
HasAmounts BalanceReportItem |
Instance details Defined in Hledger.Reports.BalanceReport Methods styleAmounts :: Map CommoditySymbol AmountStyle -> BalanceReportItem -> BalanceReportItem Source #
HasAmounts PostingsReportItem |
Instance details Defined in Hledger.Reports.PostingsReport Methods styleAmounts :: Map CommoditySymbol AmountStyle -> PostingsReportItem -> PostingsReportItem Source #
FromFormKey Text |
Instance details Defined in Web.Internal.FormUrlEncoded Methods parseFormKey :: Text -> Either Text Text
ToFormKey Text |
Instance details Defined in Web.Internal.FormUrlEncoded Methods toFormKey :: Text -> Text
QueryKeyLike Text |
Instance details Defined in Network.HTTP.Types.QueryLike Methods toQueryKey :: Text -> ByteString Source #
QueryValueLike Text |
Instance details Defined in Network.HTTP.Types.QueryLike Methods toQueryValue :: Text -> Maybe ByteString Source #
ToHtml Text |
Instance details Defined in Lucid.Base Methods toHtml :: forall (m :: Type -> Type). Monad m => Text -> HtmlT m () Source # toHtmlRaw :: forall (m :: Type -> Type). Monad m => Text -> HtmlT m () Source #
Stream Text |

Instance details

Defined in Text.Megaparsec.Stream

Associated Types

type Token Text |
Instance details Defined in Text.Megaparsec.Stream type Token Text = Token (ShareInput Text)
type Tokens Text |
Instance details Defined in Text.Megaparsec.Stream type Tokens Text = Tokens (ShareInput Text)

Methods

tokenToChunk :: Proxy Text -> Token Text -> Tokens Text Source #

tokensToChunk :: Proxy Text -> [Token Text] -> Tokens Text Source #

chunkToTokens :: Proxy Text -> Tokens Text -> [Token Text] Source #

chunkLength :: Proxy Text -> Tokens Text -> Int Source #

chunkEmpty :: Proxy Text -> Tokens Text -> Bool Source #

take1_ :: Text -> Maybe (Token Text, Text) Source #

takeN_ :: Int -> Text -> Maybe (Tokens Text, Text) Source #

takeWhile_ :: (Token Text -> Bool) -> Text -> (Tokens Text, Text) Source #

TraversableStream Text |
Instance details Defined in Text.Megaparsec.Stream Methods reachOffset :: Int -> PosState Text -> (Maybe String, PosState Text) Source # reachOffsetNoLine :: Int -> PosState Text -> PosState Text Source #
VisualStream Text |
Instance details Defined in Text.Megaparsec.Stream Methods showTokens :: Proxy Text -> NonEmpty (Token Text) -> String Source # tokensLength :: Proxy Text -> NonEmpty (Token Text) -> Int Source #
Pretty Text |
Instance details Defined in Prettyprinter.Internal Methods pretty :: Text -> Doc ann prettyList :: [Text] -> Doc ann
Extract Text |
Instance details Defined in Text.Regex.Base.RegexLike Methods before :: Int -> Text -> Text after :: Int -> Text -> Text empty :: Text extract :: (Int, Int) -> Text -> Text
Uncons Text | Since: regex-tdfa-1.3.1
Instance details Defined in Text.Regex.TDFA.NewDFA.Uncons Methods uncons :: Text -> Maybe (Char, Text) Source #
ToHamletData Text |
Instance details Defined in Text.Hamlet.Runtime Methods toHamletData :: Text -> HamletData Source #
ToCss Text |
Instance details Defined in Text.Internal.Css Methods toCss :: Text -> Builder Source #
RawJS Text |
Instance details Defined in Text.Julius Methods rawJS :: Text -> RawJavascript Source #
ToJavascript Text |
Instance details Defined in Text.Julius Methods toJavascript :: Text -> Javascript Source #
ToMessage Text |
Instance details Defined in Text.Shakespeare.I18N Methods toMessage :: Text -> Text Source #
ToText Text |
Instance details Defined in Text.Shakespeare.Text Methods toText :: Text -> Builder Source #
Term Text Attribute | Some terms (like `style_`, `title_`) can be used for attributes as well as elements.
Instance details Defined in Lucid.Base Methods term :: Text -> Text -> Attribute Source # termWith :: Text -> [Attribute] -> Text -> Attribute Source #
TermRaw Text Attribute | Some termRaws (like `style_`, `title_`) can be used for attributes as well as elements.
Instance details Defined in Lucid.Base Methods termRaw :: Text -> Text -> Attribute Source # termRawWith :: Text -> [Attribute] -> Text -> Attribute Source #
RegexLike Regex Text | Since: regex-tdfa-1.3.1
Instance details Defined in Text.Regex.TDFA.Text Methods matchOnce :: Regex -> Text -> Maybe MatchArray matchAll :: Regex -> Text -> [MatchArray] matchCount :: Regex -> Text -> Int matchTest :: Regex -> Text -> Bool matchAllText :: Regex -> Text -> [MatchText Text] matchOnceText :: Regex -> Text -> Maybe (Text, MatchText Text, Text)
RenderMessage master Text |
Instance details Defined in Text.Shakespeare.I18N Methods renderMessage :: master -> [Lang] -> Text -> Text Source #
Lift Text | Since: text-1.2.4.0
Instance details Defined in Data.Text Methods lift :: Quote m => Text -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Text -> Code m Text Source #
RegexContext Regex Text Text | Since: regex-tdfa-1.3.1
Instance details Defined in Text.Regex.TDFA.Text Methods match :: Regex -> Text -> Text matchM :: MonadFail m => Regex -> Text -> m Text
RegexMaker Regex CompOption ExecOption Text | Since: regex-tdfa-1.3.1
Instance details Defined in Text.Regex.TDFA.Text Methods makeRegex :: Text -> Regex makeRegexOpts :: CompOption -> ExecOption -> Text -> Regex makeRegexM :: MonadFail m => Text -> m Regex makeRegexOptsM :: MonadFail m => CompOption -> ExecOption -> Text -> m Regex
(Monad m, a ~ ()) => TermRaw Text (HtmlT m a) | Given children immediately, just use that and expect no attributes.
Instance details Defined in Lucid.Base Methods termRaw :: Text -> Text -> HtmlT m a Source # termRawWith :: Text -> [Attribute] -> Text -> HtmlT m a Source #
Stream (NoShareInput Text) |

Instance details

Defined in Text.Megaparsec.Stream

Associated Types

type Token (NoShareInput Text) |
Instance details Defined in Text.Megaparsec.Stream type Token (NoShareInput Text) = Char
type Tokens (NoShareInput Text) |
Instance details Defined in Text.Megaparsec.Stream type Tokens (NoShareInput Text) = Text

Methods

tokenToChunk :: Proxy (NoShareInput Text) -> Token (NoShareInput Text) -> Tokens (NoShareInput Text) Source #

tokensToChunk :: Proxy (NoShareInput Text) -> [Token (NoShareInput Text)] -> Tokens (NoShareInput Text) Source #

chunkToTokens :: Proxy (NoShareInput Text) -> Tokens (NoShareInput Text) -> [Token (NoShareInput Text)] Source #

chunkLength :: Proxy (NoShareInput Text) -> Tokens (NoShareInput Text) -> Int Source #

chunkEmpty :: Proxy (NoShareInput Text) -> Tokens (NoShareInput Text) -> Bool Source #

take1_ :: NoShareInput Text -> Maybe (Token (NoShareInput Text), NoShareInput Text) Source #

takeN_ :: Int -> NoShareInput Text -> Maybe (Tokens (NoShareInput Text), NoShareInput Text) Source #

takeWhile_ :: (Token (NoShareInput Text) -> Bool) -> NoShareInput Text -> (Tokens (NoShareInput Text), NoShareInput Text) Source #

Stream (ShareInput Text) |

Instance details

Defined in Text.Megaparsec.Stream

Associated Types

type Token (ShareInput Text) |
Instance details Defined in Text.Megaparsec.Stream type Token (ShareInput Text) = Char
type Tokens (ShareInput Text) |
Instance details Defined in Text.Megaparsec.Stream type Tokens (ShareInput Text) = Text

Methods

tokenToChunk :: Proxy (ShareInput Text) -> Token (ShareInput Text) -> Tokens (ShareInput Text) Source #

tokensToChunk :: Proxy (ShareInput Text) -> [Token (ShareInput Text)] -> Tokens (ShareInput Text) Source #

chunkToTokens :: Proxy (ShareInput Text) -> Tokens (ShareInput Text) -> [Token (ShareInput Text)] Source #

chunkLength :: Proxy (ShareInput Text) -> Tokens (ShareInput Text) -> Int Source #

chunkEmpty :: Proxy (ShareInput Text) -> Tokens (ShareInput Text) -> Bool Source #

take1_ :: ShareInput Text -> Maybe (Token (ShareInput Text), ShareInput Text) Source #

takeN_ :: Int -> ShareInput Text -> Maybe (Tokens (ShareInput Text), ShareInput Text) Source #

takeWhile_ :: (Token (ShareInput Text) -> Bool) -> ShareInput Text -> (Tokens (ShareInput Text), ShareInput Text) Source #

ToAttributes [(Text, Text)] |
Instance details Defined in Text.Hamlet Methods toAttributes :: [(Text, Text)] -> [(Text, Text)] Source #
Ord (ParseError Text HledgerParseErrorData) |

Instance details

Defined in Hledger.Utils.Parse

Methods

compare :: ParseError Text HledgerParseErrorData -> ParseError Text HledgerParseErrorData -> Ordering Source #

(<) :: ParseError Text HledgerParseErrorData -> ParseError Text HledgerParseErrorData -> Bool Source #

(<=) :: ParseError Text HledgerParseErrorData -> ParseError Text HledgerParseErrorData -> Bool Source #

(>) :: ParseError Text HledgerParseErrorData -> ParseError Text HledgerParseErrorData -> Bool Source #

(>=) :: ParseError Text HledgerParseErrorData -> ParseError Text HledgerParseErrorData -> Bool Source #

max :: ParseError Text HledgerParseErrorData -> ParseError Text HledgerParseErrorData -> ParseError Text HledgerParseErrorData Source #

min :: ParseError Text HledgerParseErrorData -> ParseError Text HledgerParseErrorData -> ParseError Text HledgerParseErrorData Source #

ToAttributes (Text, Text) |
Instance details Defined in Text.Hamlet Methods toAttributes :: (Text, Text) -> [(Text, Text)] Source #
HasAmounts b => HasAmounts (Text, PeriodicReport a b, Bool) |
Instance details Defined in Hledger.Reports.ReportTypes Methods styleAmounts :: Map CommoditySymbol AmountStyle -> (Text, PeriodicReport a b, Bool) -> (Text, PeriodicReport a b, Bool) Source #
type ChunkElem Text |
Instance details Defined in Data.Attoparsec.Internal.Types type ChunkElem Text = Char
type State Text |
Instance details Defined in Data.Attoparsec.Internal.Types type State Text = Buffer
type Item Text |
Instance details Defined in Data.Text type Item Text = Char
type Token Text |
Instance details Defined in Text.Megaparsec.Stream type Token Text = Token (ShareInput Text)
type Tokens Text |
Instance details Defined in Text.Megaparsec.Stream type Tokens Text = Tokens (ShareInput Text)
type Token (NoShareInput Text) |
Instance details Defined in Text.Megaparsec.Stream type Token (NoShareInput Text) = Char
type Token (ShareInput Text) |
Instance details Defined in Text.Megaparsec.Stream type Token (ShareInput Text) = Char
type Tokens (NoShareInput Text) |
Instance details Defined in Text.Megaparsec.Stream type Tokens (NoShareInput Text) = Text
type Tokens (ShareInput Text) |
Instance details Defined in Text.Megaparsec.Stream type Tokens (ShareInput Text) = Text

($>) :: Functor f => f a -> b -> f b infixl 4 Source #

Flipped version of `<$`.

#### Examples

Expand

Replace the contents of a ``Maybe` `Int`` with a constant `String`:

    >>> Nothing $> "foo"
    Nothing

    >>> Just 90210 $> "foo"
    Just "foo"

Replace the contents of an ``Either` `Int` `Int`` with a constant `String`, resulting in an ``Either` `Int` `String``:

    >>> Left 8675309 $> "foo"
    Left 8675309

    >>> Right 8675309 $> "foo"
    Right "foo"

Replace each element of a list with a constant `String`:

    >>> [1,2,3] $> "foo"
    ["foo","foo","foo"]

Replace the second element of a pair with a constant `String`:

    >>> (1,2) $> "foo"
    (1,"foo")

Since: base-4.7.0.0

formatRealFloat :: RealFloat a => a -> FieldFormatter Source #

Formatter for `RealFloat` values.

Since: base-4.7.0.0

(<&>) :: Functor f => f a -> (a -> b) -> f b infixl 1 Source #

Flipped version of `<$>`.

    (<&>) = flip fmap

#### Examples

Expand

Apply `(+1)` to a list, a `Just` and a `Right`:

    >>> Just 2 <&> (+1)
    Just 3

    >>> [1,2,3] <&> (+1)
    [2,3,4]

    >>> Right 3 <&> (+1)
    Right 4

Since: base-4.11.0.0

type ModifierParser = String -> FormatParse Source #

Type of a function that will parse modifier characters from the format string.

Since: base-4.7.0.0

type FieldFormatter = FieldFormat -> ShowS Source #

This is the type of a field formatter reified over its argument.

Since: base-4.7.0.0

data FormatParse Source #

The "format parser" walks over argument-type-specific modifier characters to find the primary format character. This is the type of its result.

Since: base-4.7.0.0

Constructors

FormatParse |

Fields

- fpModifiers :: String

  Any modifiers found.

- fpChar :: Char

  Primary format character.

- fpRest :: String

  Rest of the format string.

data FieldFormat Source #

Description of field formatting for `formatArg`. See UNIX `printf(3)` for a description of how field formatting works.

Since: base-4.7.0.0

Constructors

FieldFormat |

Fields

- fmtWidth :: Maybe Int

  Total width of the field.

- fmtPrecision :: Maybe Int

  Secondary field width specifier.

- fmtAdjust :: Maybe FormatAdjustment

  Kind of filling or padding to be done.

- fmtSign :: Maybe FormatSign

  Whether to insist on a plus sign for positive numbers.

- fmtAlternate :: Bool

  Indicates an "alternate format". See `printf(3)` for the details, which vary by argument spec.

- fmtModifiers :: String

  Characters that appeared immediately to the left of `fmtChar` in the format and were accepted by the type's `parseFormat`. Normally the empty string.

- fmtChar :: Char

  The format character `printf` was invoked with. `formatArg` should fail unless this character matches the type. It is normal to handle many different format characters for a single type.

data FormatSign Source #

How to handle the sign of a numeric field. These are mutually exclusive, with `SignPlus` taking precedence.

Since: base-4.7.0.0

Constructors

SignPlus |
SignSpace |

data FormatAdjustment Source #

Whether to left-adjust or zero-pad a field. These are mutually exclusive, with `LeftAdjust` taking precedence.

Since: base-4.7.0.0

Constructors

LeftAdjust |
ZeroPad |

class IsChar c where Source #

This class, with only the one instance, is used as a workaround for the fact that `String`, as a concrete type, is not allowable as a typeclass instance. `IsChar` is exported for backward-compatibility.

Methods

toChar :: c -> Char Source #

Since: base-4.7.0.0

fromChar :: Char -> c Source #

Since: base-4.7.0.0

#### Instances

Instances details

IsChar Char | Since: base-2.1
Instance details Defined in Text.Printf Methods toChar :: Char -> Char Source # fromChar :: Char -> Char Source #

class PrintfArg a where Source #

Typeclass of `printf`-formattable values. The `formatArg` method takes a value and a field format descriptor and either fails due to a bad descriptor or produces a `ShowS` as the result. The default `parseFormat` expects no modifiers: this is the normal case. Minimal instance: `formatArg`.

Minimal complete definition

formatArg

Methods

formatArg :: a -> FieldFormatter Source #

Since: base-4.7.0.0

parseFormat :: a -> ModifierParser Source #

Since: base-4.7.0.0

#### Instances

Instances details

PrintfArg Int16 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Int16 -> FieldFormatter Source # parseFormat :: Int16 -> ModifierParser Source #
PrintfArg Int32 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Int32 -> FieldFormatter Source # parseFormat :: Int32 -> ModifierParser Source #
PrintfArg Int64 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Int64 -> FieldFormatter Source # parseFormat :: Int64 -> ModifierParser Source #
PrintfArg Int8 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Int8 -> FieldFormatter Source # parseFormat :: Int8 -> ModifierParser Source #
PrintfArg Word16 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Word16 -> FieldFormatter Source # parseFormat :: Word16 -> ModifierParser Source #
PrintfArg Word32 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Word32 -> FieldFormatter Source # parseFormat :: Word32 -> ModifierParser Source #
PrintfArg Word64 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Word64 -> FieldFormatter Source # parseFormat :: Word64 -> ModifierParser Source #
PrintfArg Word8 | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Word8 -> FieldFormatter Source # parseFormat :: Word8 -> ModifierParser Source #
PrintfArg Text | Since: text-1.2.2.0
Instance details Defined in Data.Text Methods formatArg :: Text -> FieldFormatter Source # parseFormat :: Text -> ModifierParser Source #
PrintfArg Text | Since: text-1.2.2.0
Instance details Defined in Data.Text.Lazy Methods formatArg :: Text -> FieldFormatter Source # parseFormat :: Text -> ModifierParser Source #
PrintfArg ShortText |
Instance details Defined in Data.Text.Short.Internal Methods formatArg :: ShortText -> FieldFormatter Source # parseFormat :: ShortText -> ModifierParser Source #
PrintfArg Integer | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Integer -> FieldFormatter Source # parseFormat :: Integer -> ModifierParser Source #
PrintfArg Natural | Since: base-4.8.0.0
Instance details Defined in Text.Printf Methods formatArg :: Natural -> FieldFormatter Source # parseFormat :: Natural -> ModifierParser Source #
PrintfArg Char | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Char -> FieldFormatter Source # parseFormat :: Char -> ModifierParser Source #
PrintfArg Double | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Double -> FieldFormatter Source # parseFormat :: Double -> ModifierParser Source #
PrintfArg Float | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Float -> FieldFormatter Source # parseFormat :: Float -> ModifierParser Source #
PrintfArg Int | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Int -> FieldFormatter Source # parseFormat :: Int -> ModifierParser Source #
PrintfArg Word | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Word -> FieldFormatter Source # parseFormat :: Word -> ModifierParser Source #
IsChar c => PrintfArg [c] | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: [c] -> FieldFormatter Source # parseFormat :: [c] -> ModifierParser Source #

class HPrintfType t Source #

The `HPrintfType` class provides the variable argument magic for `hPrintf`. Its implementation is intentionally not visible from this module.

Minimal complete definition

hspr

#### Instances

Instances details

a ~ () => HPrintfType (IO a) | Since: base-4.7.0.0
Instance details Defined in Text.Printf Methods hspr :: Handle -> String -> [UPrintf] -> IO a
(PrintfArg a, HPrintfType r) => HPrintfType (a -> r) | Since: base-2.1
Instance details Defined in Text.Printf Methods hspr :: Handle -> String -> [UPrintf] -> a -> r

class PrintfType t Source #

The `PrintfType` class provides the variable argument magic for `printf`. Its implementation is intentionally not visible from this module. If you attempt to pass an argument of a type which is not an instance of this class to `printf` or `hPrintf`, then the compiler will report it as a missing instance of `PrintfArg`.

Minimal complete definition

spr

#### Instances

Instances details

a ~ () => PrintfType (IO a) | Since: base-4.7.0.0
Instance details Defined in Text.Printf Methods spr :: String -> [UPrintf] -> IO a
IsChar c => PrintfType [c] | Since: base-2.1
Instance details Defined in Text.Printf Methods spr :: String -> [UPrintf] -> [c]
(PrintfArg a, PrintfType r) => PrintfType (a -> r) | Since: base-2.1
Instance details Defined in Text.Printf Methods spr :: String -> [UPrintf] -> a -> r

printf :: PrintfType r => String -> r Source #

Format a variable number of arguments with the C-style formatting string.

    >>> printf "%s, %d, %.4f" "hello" 123 pi
    hello, 123, 3.1416

The return value is either `String` or `(`IO` a)` (which should be `(`IO` ())`, but Haskell's type system makes this hard).

The format string consists of ordinary characters and conversion specifications, which specify how to format one of the arguments to `printf` in the output string. A format specification is introduced by the `%` character; this character can be self-escaped into the format string using `%%`. A format specification ends with a format character that provides the primary information about how to format the value. The rest of the conversion specification is optional. In order, one may have flag characters, a width specifier, a precision specifier, and type-specific modifier characters.

Unlike C `printf(3)`, the formatting of this `printf` is driven by the argument type; formatting is type specific. The types formatted by `printf` "out of the box" are:

- `Integral` types, including `Char`
- `String`
- `RealFloat` types

`printf` is also extensible to support other types: see below.

A conversion specification begins with the character `%`, followed by zero or more of the following flags:

    -      left adjust (default is right adjust)
    +      always use a sign (+ or -) for signed conversions
    space  leading space for positive numbers in signed conversions
    0      pad with zeros rather than spaces
    #      use an \"alternate form\": see below

When both flags are given, `-` overrides `0` and `+` overrides space. A negative width specifier in a `*` conversion is treated as positive but implies the left adjust flag.

The "alternate form" for unsigned radix conversions is as in C `printf(3)`:

    %o           prefix with a leading 0 if needed
    %x           prefix with a leading 0x if nonzero
    %X           prefix with a leading 0X if nonzero
    %b           prefix with a leading 0b if nonzero
    %[eEfFgG]    ensure that the number contains a decimal point

Any flags are followed optionally by a field width:

    num    field width
    *      as num, but taken from argument list

The field width is a minimum, not a maximum: it will be expanded as needed to avoid mutilating a value.

Any field width is followed optionally by a precision:

    .num   precision
    .      same as .0
    .*     as num, but taken from argument list

Negative precision is taken as 0. The meaning of the precision depends on the conversion type.

    Integral    minimum number of digits to show
    RealFloat   number of digits after the decimal point
    String      maximum number of characters

The precision for Integral types is accomplished by zero-padding. If both precision and zero-pad are given for an Integral field, the zero-pad is ignored.

Any precision is followed optionally for Integral types by a width modifier; the only use of this modifier being to set the implicit size of the operand for conversion of a negative operand to unsigned:

    hh     Int8
    h      Int16
    l      Int32
    ll     Int64
    L      Int64

The specification ends with a format character:

    c      character               Integral
    d      decimal                 Integral
    o      octal                   Integral
    x      hexadecimal             Integral
    X      hexadecimal             Integral
    b      binary                  Integral
    u      unsigned decimal        Integral
    f      floating point          RealFloat
    F      floating point          RealFloat
    g      general format float    RealFloat
    G      general format float    RealFloat
    e      exponent format float   RealFloat
    E      exponent format float   RealFloat
    s      string                  String
    v      default format          any type

The "%v" specifier is provided for all built-in types, and should be provided for user-defined type formatters as well. It picks a "best" representation for the given type. For the built-in types the "%v" specifier is converted as follows:

    c      Char
    u      other unsigned Integral
    d      other signed Integral
    g      RealFloat
    s      String

Mismatch between the argument types and the format string, as well as any other syntactic or semantic errors in the format string, will cause an exception to be thrown at runtime.

Note that the formatting for `RealFloat` types is currently a bit different from that of C `printf(3)`, conforming instead to `showEFloat`, `showFFloat` and `showGFloat` (and their alternate versions `showFFloatAlt` and `showGFloatAlt`). This is hard to fix: the fixed versions would format in a backward-incompatible way. In any case the Haskell behavior is generally more sensible than the C behavior. A brief summary of some key differences:

- Haskell `printf` never uses the default "6-digit" precision used by C printf.
- Haskell `printf` treats the "precision" specifier as indicating the number of digits after the decimal point.
- Haskell `printf` prints the exponent of e-format numbers without a gratuitous plus sign, and with the minimum possible number of digits.
- Haskell `printf` will place a zero after a decimal point when possible.

hPrintf :: HPrintfType r => Handle -> String -> r Source #

Similar to `printf`, except that output is via the specified `Handle`. The return type is restricted to `(`IO` a)`.

vFmt :: Char -> FieldFormat -> FieldFormat Source #

Substitute a 'v' format character with the given default format character in the `FieldFormat`. A convenience for user-implemented types, which should support "%v".

Since: base-4.7.0.0

formatChar :: Char -> FieldFormatter Source #

Formatter for `Char` values.

Since: base-4.7.0.0

formatInt :: (Integral a, Bounded a) => a -> FieldFormatter Source #

Formatter for `Int` values.

Since: base-4.7.0.0

formatInteger :: Integer -> FieldFormatter Source #

Formatter for `Integer` values.

Since: base-4.7.0.0

perror :: String -> a Source #

Raises an `error` with a printf-specific prefix on the message string.

Since: base-4.7.0.0

errorBadFormat :: Char -> a Source #

Calls `perror` to indicate an unknown format letter for a given type.

Since: base-4.7.0.0

errorShortFormat :: a Source #

Calls `perror` to indicate that the format string ended early.

Since: base-4.7.0.0

errorMissingArgument :: a Source #

Calls `perror` to indicate that there is a missing argument in the argument list.

Since: base-4.7.0.0

errorBadArgument :: a Source #

Calls `perror` to indicate that there is a type error or similar in the given argument.

Since: base-4.7.0.0

pack :: String -> Text Source #

O(n) Convert a `String` into a `Text`. Performs replacement on invalid scalar values, so ``unpack` . `pack`` is not `id`:

    >>> Data.Text.unpack (pack "\55555")
    "\65533"

unpack :: Text -> String Source #

O(n) Convert a `Text` into a `String`.

searchPathSeparator :: Char Source #

The character that is used to separate the entries in the $PATH environment variable.

    Windows: searchPathSeparator == ';'
    Posix:   searchPathSeparator == ':'

normalise :: FilePath -> FilePath Source #

Normalise a file

- // outside of the drive can be made blank
- / -> `pathSeparator`
- ./ -> ""

Does not remove `".."`, because of symlinks.

    Posix:   normalise "/file/\\test////" == "/file/\\test/"
    Posix:   normalise "/file/./test" == "/file/test"
    Posix:   normalise "/test/file/../bob/fred/" == "/test/file/../bob/fred/"
    Posix:   normalise "../bob/fred/" == "../bob/fred/"
    Posix:   normalise "/a/../c" == "/a/../c"
    Posix:   normalise "./bob/fred/" == "bob/fred/"
    Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\"
    Windows: normalise "c:\\" == "C:\\"
    Windows: normalise "c:\\\\\\\\" == "C:\\"
    Windows: normalise "C:.\\" == "C:"
    Windows: normalise "\\\\server\\test" == "\\\\server\\test"
    Windows: normalise "//server/test" == "\\\\server\\test"
    Windows: normalise "c:/file" == "C:\\file"
    Windows: normalise "/file" == "\\file"
    Windows: normalise "\\" == "\\"
    Windows: normalise "/./" == "\\"
             normalise "." == "."
    Posix:   normalise "./" == "./"
    Posix:   normalise "./." == "./"
    Posix:   normalise "/./" == "/"
    Posix:   normalise "/" == "/"
    Posix:   normalise "bob/fred/." == "bob/fred/"
    Posix:   normalise "//home" == "/home"

dropTrailingPathSeparator :: FilePath -> FilePath Source #

Remove any trailing path separators

    dropTrailingPathSeparator "file/test/" == "file/test"
              dropTrailingPathSeparator "/" == "/"
    Windows:  dropTrailingPathSeparator "\\" == "\\"
    Posix:    not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x

makeRelative :: FilePath -> FilePath -> FilePath Source #

Contract a filename, based on a relative path. Note that the resulting path will never introduce `..` paths, as the presence of symlinks means `../b` may not reach `a/b` if it starts from `a/c`. For a worked example see this blog post.

The corresponding `makeAbsolute` function can be found in `System.Directory`.

             makeRelative "/directory" "/directory/file.ext" == "file.ext"
             Valid x => makeRelative (takeDirectory x) x `equalFilePath` takeFileName x
             makeRelative x x == "."
             Valid x y => equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y </> makeRelative y x) x
    Windows: makeRelative "C:\\Home" "c:\\home\\bob" == "bob"
    Windows: makeRelative "C:\\Home" "c:/home/bob" == "bob"
    Windows: makeRelative "C:\\Home" "D:\\Home\\Bob" == "D:\\Home\\Bob"
    Windows: makeRelative "C:\\Home" "C:Home\\Bob" == "C:Home\\Bob"
    Windows: makeRelative "/Home" "/home/bob" == "bob"
    Windows: makeRelative "/" "//" == "//"
    Posix:   makeRelative "/Home" "/home/bob" == "/home/bob"
    Posix:   makeRelative "/home/" "/home/bob/foo/bar" == "bob/foo/bar"
    Posix:   makeRelative "/fred" "bob" == "bob"
    Posix:   makeRelative "/file/test" "/file/test/fred" == "fred"
    Posix:   makeRelative "/file/test" "/file/test/fred/" == "fred/"
    Posix:   makeRelative "some/path" "some/path/a/b/c" == "a/b/c"

(</>) :: FilePath -> FilePath -> FilePath infixr 5 Source #

Combine two paths with a path separator. If the second path starts with a path separator or a drive letter, then it returns the second. The intention is that `readFile (dir `</>` file)` will access the same file as `setCurrentDirectory dir; readFile file`.

    Posix:   "/directory" </> "file.ext" == "/directory/file.ext"
    Windows: "/directory" </> "file.ext" == "/directory\\file.ext"
             "directory" </> "/file.ext" == "/file.ext"
    Valid x => (takeDirectory x </> takeFileName x) `equalFilePath` x

Combined:

    Posix:   "/" </> "test" == "/test"
    Posix:   "home" </> "bob" == "home/bob"
    Posix:   "x:" </> "foo" == "x:/foo"
    Windows: "C:\\foo" </> "bar" == "C:\\foo\\bar"
    Windows: "home" </> "bob" == "home\\bob"

Not combined:

    Posix:   "home" </> "/bob" == "/bob"
    Windows: "home" </> "C:\\bob" == "C:\\bob"

Not combined (tricky):

On Windows, if a filepath starts with a single slash, it is relative to the root of the current drive. In [1], this is (confusingly) referred to as an absolute path. The current behavior of `</>` is to never combine these forms.

    Windows: "home" </> "/bob" == "/bob"
    Windows: "home" </> "\\bob" == "\\bob"
    Windows: "C:\\home" </> "\\bob" == "\\bob"

On Windows, from [1]: "If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter." The current behavior of `</>` is to never combine these forms.

    Windows: "D:\\foo" </> "C:bar" == "C:bar"
    Windows: "C:\\foo" </> "C:bar" == "C:bar"

headDef :: a -> [a] -> a Source #

lastDef :: a -> [a] -> a Source #

pathSeparator :: Char Source #

The character that separates directories. In the case where more than one character is possible, `pathSeparator` is the 'ideal' one.

    Windows: pathSeparator == '\\'
    Posix:   pathSeparator ==  '/'
    isPathSeparator pathSeparator

pathSeparators :: [Char] Source #

The list of all possible separators.

    Windows: pathSeparators == ['\\', '/']
    Posix:   pathSeparators == ['/']
    pathSeparator `elem` pathSeparators

isPathSeparator :: Char -> Bool Source #

Rather than using `(== `pathSeparator`)`, use this. Test if something is a path separator.

    isPathSeparator a == (a `elem` pathSeparators)

isSearchPathSeparator :: Char -> Bool Source #

Is the character a file separator?

    isSearchPathSeparator a == (a == searchPathSeparator)

extSeparator :: Char Source #

File extension character

    extSeparator == '.'

isExtSeparator :: Char -> Bool Source #

Is the character an extension character?

    isExtSeparator a == (a == extSeparator)

splitSearchPath :: String -> [FilePath] Source #

Take a string, split it on the `searchPathSeparator` character. Blank items are ignored on Windows, and converted to `.` on Posix. On Windows path elements are stripped of quotes.

Follows the recommendations in http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html

    Posix:   splitSearchPath "File1:File2:File3"  == ["File1","File2","File3"]
    Posix:   splitSearchPath "File1::File2:File3" == ["File1",".","File2","File3"]
    Windows: splitSearchPath "File1;File2;File3"  == ["File1","File2","File3"]
    Windows: splitSearchPath "File1;;File2;File3" == ["File1","File2","File3"]
    Windows: splitSearchPath "File1;\"File2\";File3" == ["File1","File2","File3"]

getSearchPath :: IO [FilePath] Source #

Get a list of `FILEPATH`s in the $PATH variable.

splitExtension :: FilePath -> (String, String) Source #

Split on the extension. `addExtension` is the inverse.

    splitExtension "/directory/path.ext" == ("/directory/path",".ext")
    uncurry (<>) (splitExtension x) == x
    Valid x => uncurry addExtension (splitExtension x) == x
    splitExtension "file.txt" == ("file",".txt")
    splitExtension "file" == ("file","")
    splitExtension "file/file.txt" == ("file/file",".txt")
    splitExtension "file.txt/boris" == ("file.txt/boris","")
    splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext")
    splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred")
    splitExtension "file/path.txt/" == ("file/path.txt/","")

takeExtension :: FilePath -> String Source #

Get the extension of a file, returns `""` for no extension, `.ext` otherwise.

    takeExtension "/directory/path.ext" == ".ext"
    takeExtension x == snd (splitExtension x)
    Valid x => takeExtension (addExtension x "ext") == ".ext"
    Valid x => takeExtension (replaceExtension x "ext") == ".ext"

(-<.>) :: FilePath -> String -> FilePath infixr 7 Source #

Remove the current extension and add another, equivalent to `replaceExtension`.

    "/directory/path.txt" -<.> "ext" == "/directory/path.ext"
    "/directory/path.txt" -<.> ".ext" == "/directory/path.ext"
    "foo.o" -<.> "c" == "foo.c"

replaceExtension :: FilePath -> String -> FilePath Source #

Set the extension of a file, overwriting one if already present, equivalent to `-<.>`.

    replaceExtension "/directory/path.txt" "ext" == "/directory/path.ext"
    replaceExtension "/directory/path.txt" ".ext" == "/directory/path.ext"
    replaceExtension "file.txt" ".bob" == "file.bob"
    replaceExtension "file.txt" "bob" == "file.bob"
    replaceExtension "file" ".bob" == "file.bob"
    replaceExtension "file.txt" "" == "file"
    replaceExtension "file.fred.bob" "txt" == "file.fred.txt"
    replaceExtension x y == addExtension (dropExtension x) y

(<.>) :: FilePath -> String -> FilePath infixr 7 Source #

Add an extension, even if there is already one there, equivalent to `addExtension`.

    "/directory/path" <.> "ext" == "/directory/path.ext"
    "/directory/path" <.> ".ext" == "/directory/path.ext"

dropExtension :: FilePath -> FilePath Source #

Remove last extension, and the "." preceding it.

    dropExtension "/directory/path.ext" == "/directory/path"
    dropExtension x == fst (splitExtension x)

addExtension :: FilePath -> String -> FilePath Source #

Add an extension, even if there is already one there, equivalent to `<.>`.

    addExtension "/directory/path" "ext" == "/directory/path.ext"
    addExtension "file.txt" "bib" == "file.txt.bib"
    addExtension "file." ".bib" == "file..bib"
    addExtension "file" ".bib" == "file.bib"
    addExtension "/" "x" == "/.x"
    addExtension x "" == x
    Valid x => takeFileName (addExtension (addTrailingPathSeparator x) "ext") == ".ext"
    Windows: addExtension "\\\\share" ".txt" == "\\\\share\\.txt"

hasExtension :: FilePath -> Bool Source #

Does the given filename have an extension?

    hasExtension "/directory/path.ext" == True
    hasExtension "/directory/path" == False
    null (takeExtension x) == not (hasExtension x)

isExtensionOf :: String -> FilePath -> Bool Source #

Does the given filename have the specified extension?

    "png" `isExtensionOf` "/directory/file.png" == True
    ".png" `isExtensionOf` "/directory/file.png" == True
    ".tar.gz" `isExtensionOf` "bar/foo.tar.gz" == True
    "ar.gz" `isExtensionOf` "bar/foo.tar.gz" == False
    "png" `isExtensionOf` "/directory/file.png.jpg" == False
    "csv/table.csv" `isExtensionOf` "/data/csv/table.csv" == False

stripExtension :: String -> FilePath -> Maybe FilePath Source #

Drop the given extension from a FilePath, and the `"."` preceding it. Returns `Nothing` if the FilePath does not have the given extension, or `Just` and the part before the extension if it does.

This function can be more predictable than `dropExtensions`, especially if the filename might itself contain `.` characters.

    stripExtension "hs.o" "foo.x.hs.o" == Just "foo.x"
    stripExtension "hi.o" "foo.x.hs.o" == Nothing
    dropExtension x == fromJust (stripExtension (takeExtension x) x)
    dropExtensions x == fromJust (stripExtension (takeExtensions x) x)
    stripExtension ".c.d" "a.b.c.d"  == Just "a.b"
    stripExtension ".c.d" "a.b..c.d" == Just "a.b."
    stripExtension "baz"  "foo.bar"  == Nothing
    stripExtension "bar"  "foobar"   == Nothing
    stripExtension ""     x          == Just x

splitExtensions :: FilePath -> (FilePath, String) Source #

Split on all extensions.

    splitExtensions "/directory/path.ext" == ("/directory/path",".ext")
    splitExtensions "file.tar.gz" == ("file",".tar.gz")
    uncurry (<>) (splitExtensions x) == x
    Valid x => uncurry addExtension (splitExtensions x) == x

dropExtensions :: FilePath -> FilePath Source #

Drop all extensions.

    dropExtensions "/directory/path.ext" == "/directory/path"
    dropExtensions "file.tar.gz" == "file"
    not $ hasExtension $ dropExtensions x
    not $ any isExtSeparator $ takeFileName $ dropExtensions x

takeExtensions :: FilePath -> String Source #

Get all extensions.

    takeExtensions "/directory/path.ext" == ".ext"
    takeExtensions "file.tar.gz" == ".tar.gz"

replaceExtensions :: FilePath -> String -> FilePath Source #

Replace all extensions of a file with a new extension. Note that `replaceExtension` and `addExtension` both work for adding multiple extensions, so only required when you need to drop all extensions first.

    replaceExtensions "file.fred.bob" "txt" == "file.txt"
    replaceExtensions "file.fred.bob" "tar.gz" == "file.tar.gz"

splitDrive :: FilePath -> (FilePath, FilePath) Source #

Split a path into a drive and a path. On Posix, / is a Drive.

    uncurry (<>) (splitDrive x) == x
    Windows: splitDrive "file" == ("","file")
    Windows: splitDrive "c:/file" == ("c:/","file")
    Windows: splitDrive "c:\\file" == ("c:\\","file")
    Windows: splitDrive "\\\\shared\\test" == ("\\\\shared\\","test")
    Windows: splitDrive "\\\\shared" == ("\\\\shared","")
    Windows: splitDrive "\\\\?\\UNC\\shared\\file" == ("\\\\?\\UNC\\shared\\","file")
    Windows: splitDrive "\\\\?\\UNCshared\\file" == ("\\\\?\\","UNCshared\\file")
    Windows: splitDrive "\\\\?\\d:\\file" == ("\\\\?\\d:\\","file")
    Windows: splitDrive "/d" == ("","/d")
    Posix:   splitDrive "/test" == ("/","test")
    Posix:   splitDrive "//test" == ("//","test")
    Posix:   splitDrive "test/file" == ("","test/file")
    Posix:   splitDrive "file" == ("","file")

joinDrive :: FilePath -> FilePath -> FilePath Source #

Join a drive and the rest of the path.

    Valid x => uncurry joinDrive (splitDrive x) == x
    Windows: joinDrive "C:" "foo" == "C:foo"
    Windows: joinDrive "C:\\" "bar" == "C:\\bar"
    Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo"
    Windows: joinDrive "/:" "foo" == "/:\\foo"

takeDrive :: FilePath -> FilePath Source #

Get the drive from a filepath.

    takeDrive x == fst (splitDrive x)

dropDrive :: FilePath -> FilePath Source #

Delete the drive, if it exists.

    dropDrive x == snd (splitDrive x)

hasDrive :: FilePath -> Bool Source #

Does a path have a drive.

    not (hasDrive x) == null (takeDrive x)
    Posix:   hasDrive "/foo" == True
    Windows: hasDrive "C:\\foo" == True
    Windows: hasDrive "C:foo" == True
             hasDrive "foo" == False
             hasDrive "" == False

isDrive :: FilePath -> Bool Source #

Is an element a drive

    Posix:   isDrive "/" == True
    Posix:   isDrive "/foo" == False
    Windows: isDrive "C:\\" == True
    Windows: isDrive "C:\\foo" == False
             isDrive "" == False

splitFileName :: FilePath -> (String, String) Source #

Split a filename into directory and file. `</>` is the inverse. The first component will often end with a trailing slash.

    splitFileName "/directory/file.ext" == ("/directory/","file.ext")
    Valid x => uncurry (</>) (splitFileName x) == x || fst (splitFileName x) == "./"
    Valid x => isValid (fst (splitFileName x))
    splitFileName "file/bob.txt" == ("file/", "bob.txt")
    splitFileName "file/" == ("file/", "")
    splitFileName "bob" == ("./", "bob")
    Posix:   splitFileName "/" == ("/","")
    Windows: splitFileName "c:" == ("c:","")
    Windows: splitFileName "\\\\?\\A:\\fred" == ("\\\\?\\A:\\","fred")
    Windows: splitFileName "\\\\?\\A:" == ("\\\\?\\A:","")

replaceFileName :: FilePath -> String -> FilePath Source #

Set the filename.

    replaceFileName "/directory/other.txt" "file.ext" == "/directory/file.ext"
    Valid x => replaceFileName x (takeFileName x) == x

dropFileName :: FilePath -> FilePath Source #

Drop the filename. Unlike `takeDirectory`, this function will leave a trailing path separator on the directory.

    dropFileName "/directory/file.ext" == "/directory/"
    dropFileName x == fst (splitFileName x)
    isPrefixOf (takeDrive x) (dropFileName x)

takeFileName :: FilePath -> FilePath Source #

Get the file name.

    takeFileName "/directory/file.ext" == "file.ext"
    takeFileName "test/" == ""
    isSuffixOf (takeFileName x) x
    takeFileName x == snd (splitFileName x)
    Valid x => takeFileName (replaceFileName x "fred") == "fred"
    Valid x => takeFileName (x </> "fred") == "fred"
    Valid x => isRelative (takeFileName x)

takeBaseName :: FilePath -> String Source #

Get the base name, without an extension or path.

    takeBaseName "/directory/file.ext" == "file"
    takeBaseName "file/test.txt" == "test"
    takeBaseName "dave.ext" == "dave"
    takeBaseName "" == ""
    takeBaseName "test" == "test"
    takeBaseName (addTrailingPathSeparator x) == ""
    takeBaseName "file/file.tar.gz" == "file.tar"

replaceBaseName :: FilePath -> String -> FilePath Source #

Set the base name.

    replaceBaseName "/directory/other.ext" "file" == "/directory/file.ext"
    replaceBaseName "file/test.txt" "bob" == "file/bob.txt"
    replaceBaseName "fred" "bill" == "bill"
    replaceBaseName "/dave/fred/bob.gz.tar" "new" == "/dave/fred/new.tar"
    Valid x => replaceBaseName x (takeBaseName x) == x

hasTrailingPathSeparator :: FilePath -> Bool Source #

Is an item either a directory or the last character a path separator?

    hasTrailingPathSeparator "test" == False
    hasTrailingPathSeparator "test/" == True

addTrailingPathSeparator :: FilePath -> FilePath Source #

Add a trailing file path separator if one is not already present.

    hasTrailingPathSeparator (addTrailingPathSeparator x)
    hasTrailingPathSeparator x ==> addTrailingPathSeparator x == x
    Posix:    addTrailingPathSeparator "test/rest" == "test/rest/"

takeDirectory :: FilePath -> FilePath Source #

Get the directory name, move up one level.

              takeDirectory "/directory/other.ext" == "/directory"
              isPrefixOf (takeDirectory x) x || takeDirectory x == "."
              takeDirectory "foo" == "."
              takeDirectory "/" == "/"
              takeDirectory "/foo" == "/"
              takeDirectory "/foo/bar/baz" == "/foo/bar"
              takeDirectory "/foo/bar/baz/" == "/foo/bar/baz"
              takeDirectory "foo/bar/baz" == "foo/bar"
    Windows:  takeDirectory "foo\\bar" == "foo"
    Windows:  takeDirectory "foo\\bar\\\\" == "foo\\bar"
    Windows:  takeDirectory "C:\\" == "C:\\"

replaceDirectory :: FilePath -> String -> FilePath Source #

Set the directory, keeping the filename the same.

    replaceDirectory "root/file.ext" "/directory/" == "/directory/file.ext"
    Valid x => replaceDirectory x (takeDirectory x) `equalFilePath` x

combine :: FilePath -> FilePath -> FilePath Source #

An alias for `</>`.

splitPath :: FilePath -> [FilePath] Source #

Split a path by the directory separator.

    splitPath "/directory/file.ext" == ["/","directory/","file.ext"]
    concat (splitPath x) == x
    splitPath "test//item/" == ["test//","item/"]
    splitPath "test/item/file" == ["test/","item/","file"]
    splitPath "" == []
    Windows: splitPath "c:\\test\\path" == ["c:\\","test\\","path"]
    Posix:   splitPath "/file/test" == ["/","file/","test"]

splitDirectories :: FilePath -> [FilePath] Source #

Just as `splitPath`, but don't add the trailing slashes to each element.

             splitDirectories "/directory/file.ext" == ["/","directory","file.ext"]
             splitDirectories "test/file" == ["test","file"]
             splitDirectories "/test/file" == ["/","test","file"]
    Windows: splitDirectories "C:\\test\\file" == ["C:\\", "test", "file"]
             Valid x => joinPath (splitDirectories x) `equalFilePath` x
             splitDirectories "" == []
    Windows: splitDirectories "C:\\test\\\\\\file" == ["C:\\", "test", "file"]
             splitDirectories "/test///file" == ["/","test","file"]

joinPath :: [FilePath] -> FilePath Source #

Join path elements back together.

    joinPath z == foldr (</>) "" z
    joinPath ["/","directory/","file.ext"] == "/directory/file.ext"
    Valid x => joinPath (splitPath x) == x
    joinPath [] == ""
    Posix: joinPath ["test","file","path"] == "test/file/path"

equalFilePath :: FilePath -> FilePath -> Bool Source #

Equality of two `FILEPATH`s. If you call `System.Directory.canonicalizePath` first this has a much better chance of working. Note that this doesn't follow symlinks or DOSNAM~1s.

Similar to `normalise`, this does not expand `".."`, because of symlinks.

             x == y ==> equalFilePath x y
             normalise x == normalise y ==> equalFilePath x y
             equalFilePath "foo" "foo/"
             not (equalFilePath "/a/../c" "/c")
             not (equalFilePath "foo" "/foo")
    Posix:   not (equalFilePath "foo" "FOO")
    Windows: equalFilePath "foo" "FOO"
    Windows: not (equalFilePath "C:" "C:/")

isValid :: FilePath -> Bool Source #

Is a FilePath valid, i.e. could you create a file like it? This function checks for invalid names, and invalid characters, but does not check if length limits are exceeded, as these are typically filesystem dependent.

             isValid "" == False
             isValid "\0" == False
    Posix:   isValid "/random_ path:*" == True
    Posix:   isValid x == not (null x)
    Windows: isValid "c:\\test" == True
    Windows: isValid "c:\\test:of_test" == False
    Windows: isValid "test*" == False
    Windows: isValid "c:\\test\\nul" == False
    Windows: isValid "c:\\test\\prn.txt" == False
    Windows: isValid "c:\\nul\\file" == False
    Windows: isValid "\\\\" == False
    Windows: isValid "\\\\\\foo" == False
    Windows: isValid "\\\\?\\D:file" == False
    Windows: isValid "foo\tbar" == False
    Windows: isValid "nul .txt" == False
    Windows: isValid " nul.txt" == True

makeValid :: FilePath -> FilePath Source #

Take a FilePath and make it valid; does not change already valid FILEPATHs.

    isValid (makeValid x)
    isValid x ==> makeValid x == x
    makeValid "" == "_"
    makeValid "file\0name" == "file_name"
    Windows: makeValid "c:\\already\\/valid" == "c:\\already\\/valid"
    Windows: makeValid "c:\\test:of_test" == "c:\\test_of_test"
    Windows: makeValid "test*" == "test_"
    Windows: makeValid "c:\\test\\nul" == "c:\\test\\nul_"
    Windows: makeValid "c:\\test\\prn.txt" == "c:\\test\\prn_.txt"
    Windows: makeValid "c:\\test/prn.txt" == "c:\\test/prn_.txt"
    Windows: makeValid "c:\\nul\\file" == "c:\\nul_\\file"
    Windows: makeValid "\\\\\\foo" == "\\\\drive"
    Windows: makeValid "\\\\?\\D:file" == "\\\\?\\D:\\file"
    Windows: makeValid "nul .txt" == "nul _.txt"

isRelative :: FilePath -> Bool Source #

Is a path relative, or is it fixed to the root?

    Windows: isRelative "path\\test" == True
    Windows: isRelative "c:\\test" == False
    Windows: isRelative "c:test" == True
    Windows: isRelative "c:\\" == False
    Windows: isRelative "c:/" == False
    Windows: isRelative "c:" == True
    Windows: isRelative "\\\\foo" == False
    Windows: isRelative "\\\\?\\foo" == False
    Windows: isRelative "\\\\?\\UNC\\foo" == False
    Windows: isRelative "/foo" == True
    Windows: isRelative "\\foo" == True
    Posix:   isRelative "test/path" == True
    Posix:   isRelative "/test" == False
    Posix:   isRelative "/" == False

According to [1]:

- "A UNC name of any format [is never relative]."
- "You cannot use the "\?" prefix with a relative path."

isAbsolute :: FilePath -> Bool Source #

    not . isRelative

    isAbsolute x == not (isRelative x)

foldl1May :: (a -> a -> a) -> [a] -> Maybe a Source #

foldr1May :: (a -> a -> a) -> [a] -> Maybe a Source #

foldl1Note :: Partial => String -> (a -> a -> a) -> [a] -> a Source #

foldr1Note :: Partial => String -> (a -> a -> a) -> [a] -> a Source #

minimumMay :: Ord a => [a] -> Maybe a Source #

maximumMay :: Ord a => [a] -> Maybe a Source #

minimumNote :: (Partial, Ord a) => String -> [a] -> a Source #

maximumNote :: (Partial, Ord a) => String -> [a] -> a Source #

minimumByMay :: (a -> a -> Ordering) -> [a] -> Maybe a Source #

maximumByMay :: (a -> a -> Ordering) -> [a] -> Maybe a Source #

minimumByNote :: Partial => String -> (a -> a -> Ordering) -> [a] -> a Source #

maximumByNote :: Partial => String -> (a -> a -> Ordering) -> [a] -> a Source #

maximumBoundBy :: a -> (a -> a -> Ordering) -> [a] -> a Source #

The largest element of a list with respect to the given comparison function. The result is bounded by the value given as the first argument.

minimumBoundBy :: a -> (a -> a -> Ordering) -> [a] -> a Source #

The smallest element of a list with respect to the given comparison function. The result is bounded by the value given as the first argument.

maximumBound :: Ord a => a -> [a] -> a Source #

The largest element of a list. The result is bounded by the value given as the first argument.

minimumBound :: Ord a => a -> [a] -> a Source #

The smallest element of a list. The result is bounded by the value given as the first argument.

maximumBounded :: (Ord a, Bounded a) => [a] -> a Source #

The largest element of a list. The result is bounded by `minBound`.

minimumBounded :: (Ord a, Bounded a) => [a] -> a Source #

The largest element of a list. The result is bounded by `maxBound`.

findJust :: (a -> Bool) -> [a] -> a Source #

    findJust op = fromJust . find op

findJustDef :: a -> (a -> Bool) -> [a] -> a Source #

findJustNote :: Partial => String -> (a -> Bool) -> [a] -> a Source #

minimumDef :: Ord a => a -> [a] -> a Source #

New users are recommended to use `minimumBound` or `maximumBound` instead.

maximumDef :: Ord a => a -> [a] -> a Source #

New users are recommended to use `minimumBound` or `maximumBound` instead.

minimumByDef :: a -> (a -> a -> Ordering) -> [a] -> a Source #

New users are recommended to use `minimumBoundBy` or `maximumBoundBy` instead.

maximumByDef :: a -> (a -> a -> Ordering) -> [a] -> a Source #

New users are recommended to use `minimumBoundBy` or `maximumBoundBy` instead.

foldl1Def :: a -> (a -> a -> a) -> [a] -> a Source #

foldr1Def :: a -> (a -> a -> a) -> [a] -> a Source #

abort :: Partial => String -> a Source #

Synonym for `error`. Used for instances where the program has decided to exit because of invalid user input, or the user pressed quit etc. This function allows `error` to be reserved for programmer errors.

tailErr :: Partial => [a] -> [a] Source #

Identical to `tail`, namely that fails on an empty list. Useful to avoid the `x-partial` warning introduced in GHC 9.8.

    tailErr [] = error "Prelude.tail: empty list"
    tailErr [1,2,3] = [2,3]

headErr :: Partial => [a] -> a Source #

Identical to `head`, namely that fails on an empty list. Useful to avoid the `x-partial` warning introduced in GHC 9.8.

    headErr [] = error "Prelude.head: empty list"
    headErr [1,2,3] = 1

tailMay :: [a] -> Maybe [a] Source #

    tailMay [] = Nothing
    tailMay [1,3,4] = Just [3,4]

tailDef :: [a] -> [a] -> [a] Source #

    tailDef [12] [] = [12]
    tailDef [12] [1,3,4] = [3,4]

tailNote :: Partial => String -> [a] -> [a] Source #

    tailNote "help me" [] = error "Safe.tailNote [], help me"
    tailNote "help me" [1,3,4] = [3,4]

tailSafe :: [a] -> [a] Source #

    tailSafe [] = []
    tailSafe [1,3,4] = [3,4]

initMay :: [a] -> Maybe [a] Source #

initDef :: [a] -> [a] -> [a] Source #

initNote :: Partial => String -> [a] -> [a] Source #

initSafe :: [a] -> [a] Source #

headMay :: [a] -> Maybe a Source #

lastMay :: [a] -> Maybe a Source #

headNote :: Partial => String -> [a] -> a Source #

lastNote :: Partial => String -> [a] -> a Source #

foldl1May' :: (a -> a -> a) -> [a] -> Maybe a Source #

foldl1Note' :: Partial => String -> (a -> a -> a) -> [a] -> a Source #

scanr1May :: (a -> a -> a) -> [a] -> Maybe [a] Source #

scanl1May :: (a -> a -> a) -> [a] -> Maybe [a] Source #

scanr1Def :: [a] -> (a -> a -> a) -> [a] -> [a] Source #

scanl1Def :: [a] -> (a -> a -> a) -> [a] -> [a] Source #

scanr1Note :: Partial => String -> (a -> a -> a) -> [a] -> [a] Source #

scanl1Note :: Partial => String -> (a -> a -> a) -> [a] -> [a] Source #

cycleMay :: [a] -> Maybe [a] Source #

cycleDef :: [a] -> [a] -> [a] Source #

cycleNote :: Partial => String -> [a] -> [a] Source #

fromJustDef :: a -> Maybe a -> a Source #

An alternative name for `fromMaybe`, to fit the naming scheme of this package. Generally using `fromMaybe` directly would be considered better style.

fromJustNote :: Partial => String -> Maybe a -> a Source #

assertNote :: Partial => String -> Bool -> a -> a Source #

atMay :: [a] -> Int -> Maybe a Source #

atDef :: a -> [a] -> Int -> a Source #

atNote :: Partial => String -> [a] -> Int -> a Source #

readEitherSafe :: Read a => String -> Either String a Source #

This function provides a more precise error message than `readEither` from `base`.

readMay :: Read a => String -> Maybe a Source #

readDef :: Read a => a -> String -> a Source #

readNote :: (Partial, Read a) => String -> String -> a Source #

`readNote` uses `readEitherSafe` for the error message.

lookupJust :: (Eq a, Partial) => a -> [(a, b)] -> b Source #

    lookupJust key = fromJust . lookup key

lookupJustDef :: Eq a => b -> a -> [(a, b)] -> b Source #

lookupJustNote :: (Partial, Eq a) => String -> a -> [(a, b)] -> b Source #

elemIndexJust :: (Partial, Eq a) => a -> [a] -> Int Source #

    elemIndexJust op = fromJust . elemIndex op

elemIndexJustDef :: Eq a => Int -> a -> [a] -> Int Source #

elemIndexJustNote :: (Partial, Eq a) => String -> a -> [a] -> Int Source #

findIndexJust :: (a -> Bool) -> [a] -> Int Source #

    findIndexJust op = fromJust . findIndex op

findIndexJustDef :: Int -> (a -> Bool) -> [a] -> Int Source #

findIndexJustNote :: Partial => String -> (a -> Bool) -> [a] -> Int Source #

toEnumMay :: (Enum a, Bounded a) => Int -> Maybe a Source #

toEnumDef :: (Enum a, Bounded a) => a -> Int -> a Source #

toEnumNote :: (Partial, Enum a, Bounded a) => String -> Int -> a Source #

toEnumSafe :: (Enum a, Bounded a) => Int -> a Source #

succMay :: (Enum a, Eq a, Bounded a) => a -> Maybe a Source #

succDef :: (Enum a, Eq a, Bounded a) => a -> a -> a Source #

succNote :: (Partial, Enum a, Eq a, Bounded a) => String -> a -> a Source #

succSafe :: (Enum a, Eq a, Bounded a) => a -> a Source #

predMay :: (Enum a, Eq a, Bounded a) => a -> Maybe a Source #

predDef :: (Enum a, Eq a, Bounded a) => a -> a -> a Source #

predNote :: (Partial, Enum a, Eq a, Bounded a) => String -> a -> a Source #

predSafe :: (Enum a, Eq a, Bounded a) => a -> a Source #

indexMay :: Ix a => (a, a) -> a -> Maybe Int Source #

indexDef :: Ix a => Int -> (a, a) -> a -> Int Source #

indexNote :: (Partial, Ix a) => String -> (a, a) -> a -> Int Source #

foldl1Def' :: a -> (a -> a -> a) -> [a] -> a Source #

argsToCliOpts :: [String] -> [String] -> IO CliOpts Source #

A helper for addons/scripts: this parses hledger CliOpts from these command line arguments and add-on command names, roughly how hledger main does. If option parsing/validating fails, it exits the program with usageError. Unlike main, this does not read extra args from a config file or search for addons; to do those things, mimic the code in main for now.