Shellac-0.9.1: A framework for creating shell envinronmentsSource codeContentsIndex
System.Console.Shell.ShellMonad
Contents
The Shell monad
Output functions
Shell state accessors
Special actions
Description
This module implements a monad for use in shell commands and in evaluation functions. It is a state moand layered over IO. liftIO may be used to execute arbitrary I/O actions. However, the shellPut* commands are the preferred way to output text.
Synopsis
data Sh st a
runSh :: st -> OutputCommand -> Sh st () -> IO (CommandResult st)
shellPut :: BackendOutput -> Sh st ()
shellPutStr :: String -> Sh st ()
shellPutStrLn :: String -> Sh st ()
shellPutInfo :: String -> Sh st ()
shellPutInfoLn :: String -> Sh st ()
shellPutErr :: String -> Sh st ()
shellPutErrLn :: String -> Sh st ()
getShellSt :: Sh st st
putShellSt :: st -> Sh st ()
modifyShellSt :: (st -> st) -> Sh st ()
shellSpecial :: ShellSpecial st -> Sh st ()
The Shell monad
data Sh st a Source
The type of shell commands. This monad is a state monad layered over IO. The type parameter st allows the monad to carry around a package of user-defined state.
show/hide Instances
MonadState st (Sh st)
Monad (Sh st)
MonadIO (Sh st)
CommandFunction (Sh st ()) st
runSh :: st -> OutputCommand -> Sh st () -> IO (CommandResult st)Source
Execute a shell action
Output functions
shellPut :: BackendOutput -> Sh st ()Source
Output a tagged string to the console
shellPutStr :: String -> Sh st ()Source
Prints a regular output string
shellPutStrLn :: String -> Sh st ()Source
Prints regular output with a line terminator
shellPutInfo :: String -> Sh st ()Source
Prints an informational output string
shellPutInfoLn :: String -> Sh st ()Source
Prints an informational output string with a line terminator
shellPutErr :: String -> Sh st ()Source
Prints an error output string
shellPutErrLn :: String -> Sh st ()Source
Prints and error output string with a line terminator
Shell state accessors
getShellSt :: Sh st stSource
Get the current shell state
putShellSt :: st -> Sh st ()Source
Set the shell state
modifyShellSt :: (st -> st) -> Sh st ()Source
Apply the given funtion to the shell state
Special actions
shellSpecial :: ShellSpecial st -> Sh st ()Source
Schedule a shell "special" action. Only the last call to this function will affect the shell's behavior! It modifies a bit of state that is overwritten on each call.
Produced by Haddock version 2.3.0