haskeline-0.7.4.0: A command-line interface for user input, written in Haskell.

Safe Haskell | None
Language | Haskell98

System.Console.Haskeline.History

Description

This module provides a low-level API to the line history stored in the `InputT` monad transformer.

For most application, it should suffice to instead use the following `Settings` flags:

- `autoAddHistory`: add nonblank lines to the command history (`True` by default).
- `historyFile`: read/write the history to a file before and after the line input session.

If you do want custom history behavior, you may need to disable the above default setting(s).

Synopsis

- data History
- emptyHistory :: History
- addHistory :: String -> History -> History
- addHistoryUnlessConsecutiveDupe :: String -> History -> History
- addHistoryRemovingAllDupes :: String -> History -> History
- historyLines :: History -> [String]
- readHistory :: FilePath -> IO History
- writeHistory :: FilePath -> History -> IO ()
- stifleHistory :: Maybe Int -> History -> History
- stifleAmount :: History -> Maybe Int

# Documentation

data History #

Instances

Show History # |
Methods showsPrec :: Int -> History -> ShowS Source # show :: History -> String Source # showList :: [History] -> ShowS Source #

emptyHistory :: History #

addHistory :: String -> History -> History #

addHistoryUnlessConsecutiveDupe :: String -> History -> History #

Add a line to the history unless it matches the previously recorded line.

addHistoryRemovingAllDupes :: String -> History -> History #

Add a line to the history, and remove all previous entries which are the same as it.

historyLines :: History -> [String] #

The input lines stored in the history (newest first)

readHistory :: FilePath -> IO History #

Reads the line input history from the given file. Returns `emptyHistory` if the file does not exist or could not be read.

writeHistory :: FilePath -> History -> IO () #

Writes the line history to the given file. If there is an error when writing the file, it will be ignored.

stifleHistory :: Maybe Int -> History -> History #

Limit the number of lines stored in the history.

stifleAmount :: History -> Maybe Int #

The maximum number of lines stored in the history. If `Nothing`, the history storage is unlimited.