Shellac 0.9.5 → 0.9.5.1
raw patch · 3 files changed
+32/−5 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ System.Console.Shell.ShellMonad: extractContext :: Sh st (ShellContext st)
+ System.Console.Shell.ShellMonad: runWithContext :: ShellContext st -> Sh st a -> IO (a, CommandResult st)
+ System.Console.Shell.ShellMonad: type ShellContext st = (CommandResult st, OutputCommand)
+ System.Console.Shell.ShellMonad: updateCommandResult :: CommandResult st -> Sh st ()
- System.Console.Shell: cmd :: (CommandFunction f st) => String -> f -> String -> ShellCommand st
+ System.Console.Shell: cmd :: CommandFunction f st => String -> f -> String -> ShellCommand st
- System.Console.Shell: completableLabel :: (Completion compl st) => compl -> String
+ System.Console.Shell: completableLabel :: Completion compl st => compl -> String
- System.Console.Shell: complete :: (Completion compl st) => compl -> (st -> String -> IO [String])
+ System.Console.Shell: complete :: Completion compl st => compl -> (st -> String -> IO [String])
Files
- Shellac.cabal +2/−2
- src/System/Console/Shell/ShellMonad.hs +26/−0
- src/System/Console/Shell/Types.hs +4/−3
Shellac.cabal view
@@ -1,7 +1,7 @@ Name: Shellac-Cabal-Version: >= 1.2+Cabal-Version: >= 1.2.3 Build-Type: Simple-Version: 0.9.5+Version: 0.9.5.1 License: BSD3 License-File: LICENSE Author: Robert Dockins
src/System/Console/Shell/ShellMonad.hs view
@@ -26,6 +26,12 @@ -- * Special actions , shellSpecial+++-- * Extracting and using the shell context+, ShellContext+, extractContext, runWithContext, updateCommandResult+ ) where import Control.Monad.Reader@@ -87,3 +93,23 @@ instance MonadState st (Sh st) where get = getShellSt put = putShellSt++-- | The total context held by the shell, with @'CommandResult' st@+-- being mutable and 'OutputCommand' immutable+type ShellContext st = (CommandResult st, OutputCommand)++-- | Extract the current shell context for future use, see 'runWithContext'+extractContext :: Sh st (ShellContext st)+extractContext = (Sh . StateT) $ \s -> do+ imC <- ask + return ((s, imC), s)++-- | Run a shell with the supplied context, useful if you need to+-- invoke a shell within a new IO context, for example when using+-- 'System.Timeout.timeout'+runWithContext :: ShellContext st -> Sh st a -> IO (a, CommandResult st)+runWithContext (mC, imC) = (flip runReaderT) imC . (flip runStateT) mC . unSh++-- | Update the mutable context of this shell+updateCommandResult :: CommandResult st -> Sh st ()+updateCommandResult s = (Sh . StateT) $ \_ -> return (() , s)
src/System/Console/Shell/Types.hs view
@@ -18,8 +18,9 @@ -- | Datatype describing the style of shell commands. This -- determines how shell input is parsed. data CommandStyle- = OnlyCommands -- ^ Indicates that all input is to be interpreted as shell commands; no- -- input will be passed to the evaluation function.+ = OnlyCommands -- ^ Indicates that all input is to be interpreted as shell commands;+ -- input is only passed to the evaluation fuction if it cannot be+ -- parsed as a command. | CharPrefixCommands Char -- ^ Indicates that commands are prefixed with a particular character. -- Colon \':\' is the default character (a la GHCi). | SingleCharCommands -- ^ Commands consist of a single character.@@ -73,7 +74,7 @@ -- The type parameter @st@ allows the monad to carry around a package of -- user-defined state. newtype Sh st a = Sh { unSh :: StateT (CommandResult st) (ReaderT OutputCommand IO) a }- deriving (Monad, MonadIO)+ deriving (Monad, MonadIO, MonadFix, Functor) ------------------------------------------------------------------------ -- The shell description and utility functions