Commit 7502ca2f authored by Bakhtiyar Neyman's avatar Bakhtiyar Neyman
Browse files

Fixing a trivial bug and a comment.

parent 0640f912
{- |
{- |
A rich user interface for line input in command-line programs. Haskeline is
Unicode-aware and runs both on POSIX-compatible systems and on Windows.
Unicode-aware and runs both on POSIX-compatible systems and on Windows.
Users may customize the interface with a @~/.haskeline@ file; see
<http://trac.haskell.org/haskeline/wiki/UserPrefs> for more information.
......@@ -10,10 +10,10 @@ An example use of this library for a simple read-eval-print loop (REPL) is the
following:
> import System.Console.Haskeline
>
>
> main :: IO ()
> main = runInputT defaultSettings loop
> where
> where
> loop :: InputT IO ()
> loop = do
> minput <- getInputLine "% "
......@@ -184,7 +184,7 @@ maybeAddHistory result = do
settings :: Settings m <- InputT ask
histDupes <- InputT $ asks historyDuplicates
case result of
Just line | autoAddHistory settings && not (all isSpace line)
Just line | autoAddHistory settings && not (all isSpace line)
-> let adder = case histDupes of
AlwaysAdd -> addHistory
IgnoreConsecutive -> addHistoryUnlessConsecutiveDupe
......@@ -215,9 +215,9 @@ getPrintableChar fops = do
case fmap isPrint c of
Just False -> getPrintableChar fops
_ -> return c
getInputCmdChar :: MonadException m => TermOps -> String -> InputT m (Maybe Char)
getInputCmdChar tops prefix = runInputCmdT tops
getInputCmdChar tops prefix = runInputCmdT tops
$ runCommandLoop tops prefix acceptOneChar emptyIM
acceptOneChar :: Monad m => KeyCommand m InsertMode (Maybe Char)
......@@ -236,7 +236,7 @@ When using terminal-style interaction, the masking character (if given) will rep
When using file-style interaction, this function turns off echoing while reading
the line of input.
-}
getPassword :: MonadException m => Maybe Char -- ^ A masking character; e.g., @Just \'*\'@
-> String -> InputT m (Maybe String)
getPassword x = promptedInput
......@@ -257,7 +257,7 @@ getPassword x = promptedInput
, ctrlChar 'l' +> clearScreenCmd >|> loop'
]
loop' = keyCommand loop
{- $history
The 'InputT' monad transformer provides direct, low-level access to the user's line history state.
......@@ -303,7 +303,7 @@ every time Ctrl-C is pressed.
> tryAction = wrapInterrupt loop
> where loop = handle (\Interrupt -> outputStrLn "Cancelled; try again." >> loop)
> someLongAction
This behavior differs from GHC's built-in Ctrl-C handling, which
may immediately terminate the program after the second time that the user presses
Ctrl-C.
......@@ -314,18 +314,18 @@ withInterrupt act = do
rterm <- InputT ask
liftIOOp_ (wrapInterrupt rterm) act
-- | Catch and handle an exception of type 'Interrupt'.
-- | Catch and handle an exception of type 'Interrupt'.
--
-- > handleInterrupt f = handle $ \Interrupt -> f
handleInterrupt :: MonadException m => m a -> m a -> m a
handleInterrupt f = handle $ \Interrupt -> f
-- | Return a print function, which is thread-safe and preserves prompt in terminal-style interaction.
{- | Return a printing function, which in terminal-style interactions is
thread-safe and may be run concurrently with user input without affecting the
prompt. -}
getExternalPrint :: MonadException m => InputT m (String -> IO ())
getExternalPrint = do
rterm <- InputT ask
return $ case termOps rterm of
Right _ -> putStrOut rterm
Left tops -> externalPrint tops
\ No newline at end of file
......@@ -295,7 +295,7 @@ posixRunTerm hs layoutGetters keys wrapGetEvent evalBackend = do
}
, closeTerm = do
flushEventQueue (putStrOut fileRT) ch
closeHandles hs
closeTerm fileRT
}
type PosixT m = ReaderT Encoder (ReaderT Handles m)
......
Name: haskeline
Cabal-Version: >=1.10
Version: 0.7.2.3
Version: 0.7.2.2
Category: User Interfaces
License: BSD3
License-File: LICENSE
......@@ -9,7 +9,7 @@ Author: Judah Jacobson
Maintainer: Judah Jacobson <judah.jacobson@gmail.com>
Category: User Interfaces
Synopsis: A command-line interface for user input, written in Haskell.
Description:
Description:
Haskeline provides a user interface for line input in command-line
programs. This library is similar in purpose to readline, but since
it is written in Haskell it is (hopefully) more easily used in other
......@@ -54,7 +54,7 @@ Library
directory>=1.1 && < 1.3, bytestring>=0.9 && < 0.11,
filepath >= 1.2 && < 1.5, transformers >= 0.2 && < 0.6
Default-Language: Haskell98
Default-Extensions:
Default-Extensions:
ForeignFunctionInterface, Rank2Types, FlexibleInstances,
TypeSynonymInstances
FlexibleContexts, ExistentialQuantification
......@@ -116,7 +116,7 @@ Library
install-includes: h_iconv.h
Other-modules: System.Console.Haskeline.Backend.Posix.IConv
}
Other-modules:
Other-modules:
System.Console.Haskeline.Backend.Posix
System.Console.Haskeline.Backend.Posix.Encoder
System.Console.Haskeline.Backend.DumbTerm
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment