[haskeline] #112: Multi-line prompt
haskeline
haskeline at projects.haskell.org
Wed Oct 27 09:14:02 EDT 2010
#112: Multi-line prompt
------------------------+---------------------------------------------------
Reporter: judah | Owner:
Type: enhancement | Status: new
Priority: minor | Milestone:
Version: | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by vivian):
{{{
getMultiLine :: MonadException m =>
-> ([String] -> m (Bool,String)) -- ^ True to continue
requesting lines
-- initially called with
`[]' for first prompt
-> (String -> InputT m (Maybe String)) -- ^ prompt -> action
to get another line
-> InputT m [String]
getMultiLine test getLine = do
hs <- go []
maybeAddHistory (Just $ concat $ intersperse ['\n'] hs)
return hs
where
go previous = do
(another,prompt) <- lift $ test previous
if another
then do
mb_input <- getLine prompt
case mb_input of
Nothing -> return previous
Just input -> go $ previous ++ [input]
else return previous
}}}
--
Ticket URL: <http://trac.haskell.org/haskeline/ticket/112#comment:4>
haskeline <http://example.org/>
My example project
More information about the Haskeline
mailing list