[GHC] #5624: Delay Errors Until Runtime

GHC cvs-ghc at haskell.org
Fri Nov 11 06:49:57 CET 2011


#5624: Delay Errors Until Runtime
---------------------------------+------------------------------------------
    Reporter:  atnnn             |       Owner:  atnnn       
        Type:  feature request   |      Status:  new         
    Priority:  normal            |   Component:  Compiler    
     Version:  7.3               |    Keywords:              
    Testcase:                    |   Blockedby:              
          Os:  Unknown/Multiple  |    Blocking:              
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown
---------------------------------+------------------------------------------

Comment(by atnnn):

 It works in ghci too:

 {{{
 Prelude> :set -XDelayErrors
 Prelude> head ['a', Nothing] == 'a'
 True
 Prelude> print "foo" >> print bar
 "foo"
 *** Exception: <interactive>:16:22: Not in scope: `bar'
 Prelude> let f x = if x == 3 then 'a' else Nothing
 Prelude> :t f
 f :: (Eq a, Num a) => a -> Char
 Prelude> f 3
 'a'
 Prelude> f 4
 *** Exception: <interactive>:17:35:
     Couldn't match expected type `Char' with actual type `Maybe a0'
     In the expression: Nothing
     In the expression: if x == 3 then 'a' else Nothing
     In an equation for `f': f x = if x == 3 then 'a' else Nothing

 }}}

 My TODO list is:

 - Add a new type of exception and use it instead of calling error

 - Identify the compile-time warnings as such (they appear like errors)

 - Use original code for pretty printing errors. ([1,2,'a'] gives "No
 instance for (Num Char) in the expression 1 in the expression [1, error
 "...", 'a'])

 - Add some tests

 I have successfully used this feature to develop it. It's great to be able
 to load code into into ghci and be able to use :t and :i even when errors
 are present.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5624#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list