#1200: ghci scripts ending in printf lines fail with Exception: 
Prelude.undefined
----------------------------+-----------------------------------------------
 Reporter:  dons            |          Owner:         
     Type:  bug             |         Status:  new    
 Priority:  normal          |      Milestone:  6.8    
Component:  libraries/base  |        Version:  6.6    
 Severity:  normal          |     Resolution:         
 Keywords:                  |     Difficulty:  Unknown
 Testcase:                  |   Architecture:  Unknown
       Os:  Unknown         |  
----------------------------+-----------------------------------------------
Changes (by igloo):

  * component:  GHCi => libraries/base
  * milestone:  => 6.8

Comment:

 The problem is that `main :: IO a`, and ghci now tries to print out the
 value resulting from running an IO action (unless that value has type (),
 which is why annotations fix it). runhaskell probably shouldn't share this
 behaviour in my opinion.

 printf has things like
 {{{
 instance PrintfType (IO a) where
     spr fmt args = do
     putStr (uprintf fmt (reverse args))
     return undefined
 }}}
 so ghci tries to print out this undefined value.

 We could change the instance to `IO ()` so that we could remove the last
 line, but that's probably not portable enough. Making it
 {{{
 class Unit a where unit :: a
 instance Unit () where unit = ()
 instance Unit a => PrintfType (IO a) where
     ...
     return unit
 }}}
 would work, but would give some possibly confusing type errors when a type
 `IO a` is infered.

 Or we could just change the `undefined`s to `error`s with an explanatory
 message.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1200>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to