#1363: Sourcing multi-line scripts in GHCi: track line numbers, and bail out 
after
first error
---------------------------------+------------------------------------------
    Reporter:  Frederik          |        Owner:                            
        Type:  feature request   |       Status:  new                       
    Priority:  normal            |    Milestone:  _|_                       
   Component:  GHCi              |      Version:  6.6                       
    Keywords:  multiline script  |     Testcase:                            
   Blockedby:                    |   Difficulty:  Moderate (less than a day)
          Os:  Unknown/Multiple  |     Blocking:                            
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown              
---------------------------------+------------------------------------------

Comment(by vivian):

 I think `:script` is better.

 It would be nice to have the current line number and input file (or
 "<interactive>") threaded through the commands so we can use the same
 system for both keyboard interaction and file scripts.  The only problem
 there is that
 {{{
 hscParseThing :: (Outputable thing, GhcMonad m)
               => Lexer.P thing
               -> DynFlags -> String
               -> m thing
         -- Nothing => Parse error (message already printed)
         -- Just x  => success
 hscParseThing parser dflags str
  = (liftIO $ showPass dflags "Parser") >>
       {-# SCC "Parser" #-} do

       buf <- liftIO $ stringToStringBuffer str

       let loc  = mkSrcLoc (fsLit "<interactive>") 1 1
 }}}
 is polymorphic over `GhcMonad`.  `hscParseThing` is where the line number
 and 'session name' get used.  It does not make sense to store line number
 and session name in the Ghc monad, but it does in GHCiState of GHCi monad.

 I could write a version of this function specialised for the GHCi monad.
 This would require adding fields
 {{{
 data GHCiState = GHCiState
    ...
    input_file  :: Maybe String -- ^ the input file or Nothing =
 "<interactive>"
    line_number :: Int          -- ^ input line number, could be used to
 annotate session
                                --   or track history
    ...
 }}}
 and reproducing other code from `GhcMonad`.

 Another alternative is to provide versions of {{{HscMain.hs: hscStmt,
 hscParse}}} that take additional arguments {{{Int, Maybe String}}}.

 Objections?  Suggestions?

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1363#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to