haskeline-class-0.6: Class interface for working with HaskelineSource codeContentsIndex
PortabilityFlexibleInstances, MultiPatamTypeClasses, UndecidableInstances, GeneralizedNewtypeDeriving
MaintainerAntoine Latter <aslatter@gmail.com>

Haskeline provides all of its functionality within the scope of a monad transformer. This module adds two pieces to this:

  • - Introduced here is a type-class which defines the operations supported by the Haskeline monad transformer - MonadHaskeline
  • - Also is a newtype wrapper around Haskeline's InputT, called HaskelineT. Sadly, InputT defines ints own instance of the mtl MonadState, which is no good for folks wanting to use InputT in an existing monad transformer stack.

HaskelineT also has an instance of MonadState, but it merely lifts the functions further in the transformer stack.

Large portions of the Haskeline functionality are re-exported here for convinience.

data HaskelineT m a
runHaskelineT :: MonadException m => Settings m -> HaskelineT m a -> m a
runHaskelineTWithPrefs :: MonadException m => Prefs -> Settings m -> HaskelineT m a -> m a
class MonadException m => MonadHaskeline m where
getInputLine :: String -> m (Maybe String)
getInputChar :: String -> m (Maybe Char)
outputStr :: String -> m ()
outputStrLn :: String -> m ()
data Settings m = Settings {
complete :: CompletionFunc m
historyFile :: Maybe FilePath
autoAddHistory :: Bool
defaultSettings :: MonadIO m => Settings m
setComplete :: CompletionFunc m -> Settings m -> Settings m
data Prefs
readPrefs :: FilePath -> IO Prefs
defaultPrefs :: Prefs
data Interrupt = Interrupt
handleInterrupt :: MonadException m => m a -> m a -> m a
module System.Console.Haskeline.Completion
module System.Console.Haskeline.MonadException
data HaskelineT m a Source
show/hide Instances
runHaskelineT :: MonadException m => Settings m -> HaskelineT m a -> m aSource
runHaskelineTWithPrefs :: MonadException m => Prefs -> Settings m -> HaskelineT m a -> m aSource
class MonadException m => MonadHaskeline m whereSource
getInputLine :: String -> m (Maybe String)Source
getInputChar :: String -> m (Maybe Char)Source
outputStr :: String -> m ()Source
outputStrLn :: String -> m ()Source
show/hide Instances
data Settings m Source
Application-specific customizations to the user interface.
complete :: CompletionFunc mCustom tab completion.
historyFile :: Maybe FilePathWhere to read/write the history at the start and end of each line input session.
autoAddHistory :: BoolIf True, each nonblank line returned by getInputLine will be automatically added to the history.
show/hide Instances
Monad m => MonadReader (Settings m) (InputT m)
defaultSettings :: MonadIO m => Settings mSource

A useful default. In particular:

defaultSettings = Settings { complete = completeFilename, historyFile = Nothing, autoAddHistory = True }
setComplete :: CompletionFunc m -> Settings m -> Settings mSource
Because complete is the only field of Settings depending on m, the expression defaultSettings {completionFunc = f} leads to a type error from being too general. This function works around that issue, and may become unnecessary if another field depending on m is added.
data Prefs Source

Prefs allow the user to customize the line-editing interface. They are read by default from ~/.haskeline; to override that behavior, use readPrefs and runInputTWithPrefs.

Each line of a .haskeline file defines one field of the Prefs datatype; field names are case-insensitive and unparseable lines are ignored. For example:

editMode: Vi completionType: MenuCompletion maxhistorysize: Just 40
show/hide Instances
Show Prefs
Monad m => MonadReader Prefs (InputT m)
readPrefs :: FilePath -> IO PrefsSource
Read Prefs from a given file. If there is an error reading the file, the defaultPrefs will be returned.
defaultPrefs :: PrefsSource
The default preferences which may be overwritten in the .haskeline file.
data Interrupt Source
show/hide Instances
:: MonadException m
=> m aComputation to run
-> m a
-> m a
Catch and handle an exception of type Interrupt.
module System.Console.Haskeline.Completion
module System.Console.Haskeline.MonadException
Produced by Haddock version 2.6.0