| Portability | FlexibleInstances, MultiPatamTypeClasses, UndecidableInstances, GeneralizedNewtypeDeriving |
|---|---|
| Stability | experimental |
| Maintainer | Antoine Latter <aslatter@gmail.com> |
System.Console.Haskeline.Class
Description
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
- 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 {}
- 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
Documentation
data HaskelineT m a Source
Instances
| MonadTrans HaskelineT | |
| MonadState s m => MonadState s (HaskelineT m) | |
| Monad m => Monad (HaskelineT m) | |
| Monad m => Functor (HaskelineT m) | |
| Monad m => Applicative (HaskelineT m) | |
| MonadIO m => MonadIO (HaskelineT m) | |
| MonadException m => MonadException (HaskelineT m) | |
| MonadException m => MonadHaskeline (HaskelineT m) |
runHaskelineT :: MonadException m => Settings m -> HaskelineT m a -> m aSource
Run a line-reading application, reading user Prefs from
~/.haskeline
runHaskelineTWithPrefs :: MonadException m => Prefs -> Settings m -> HaskelineT m a -> m aSource
class MonadException m => MonadHaskeline m whereSource
Methods
getInputLine :: String -> m (Maybe String)Source
getInputChar :: String -> m (Maybe Char)Source
outputStr :: String -> m ()Source
outputStrLn :: String -> m ()Source
Instances
| MonadException m => MonadHaskeline (InputT m) | |
| MonadException m => MonadHaskeline (HaskelineT m) | |
| MonadHaskeline m => MonadHaskeline (StateT s m) |
data Settings m
Application-specific customizations to the user interface.
Constructors
| Settings | |
Fields
| |
defaultSettings :: MonadIO m => Settings m
A useful default. In particular:
defaultSettings = Settings {
complete = completeFilename,
historyFile = Nothing,
autoAddHistory = True
}
setComplete :: CompletionFunc m -> Settings m -> Settings m
data Prefs
Prefs allow the user to customize the terminal-style 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
readPrefs :: FilePath -> IO Prefs
Read Prefs from a given file. If there is an error reading the file,
the defaultPrefs will be returned.
The default preferences which may be overwritten in the
.haskeline file.
Arguments
| :: MonadException m | |
| => m a | Handler to run if Ctrl-C is pressed |
| -> m a | Computation to run |
| -> m a |
Catch and handle an exception of type Interrupt.