#5532: Variants of ticket #1200 still cropping up
---------------------------------+------------------------------------------
Reporter: rrnewton | Owner:
Type: bug | Status: new
Priority: normal | Component: libraries/base
Version: 7.0.3 | Keywords: Printf undefined
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
I see that ticket #1200 from several years back is currently closed.
However, I was in the midst of writing some simple tests to help myself
understand ReaderT ContT interaction and again ran into these frustrating
`undefined` errors coming from printf:
{{{
import Control.Monad.Cont as C
import qualified Control.Monad.Reader as R
import Data.IORef
import Text.Printf
test ref = do
x <- R.ask
liftIO$ printf "Observed value %d before callCC\n" x
callCC$ \cont -> do
y <- R.ask
liftIO$ writeIORef ref cont
liftIO$ printf "Observed value %d inside callCC\n" y
z <- R.ask
liftIO$ printf "Observed value %d in invoked continuation\n" z
main = do ref <- newIORef (error "unused")
let test' = do test ref
-- Uncommenting the following will fix it:
-- return ()
m1 = R.runReaderT test' (100::Int)
m2 = C.runContT m1 (\ () -> return ())
m2
putStrLn "Done with main."
}}}
I see only two occurrences of `undefined` in Printf.hs. Is there any
disadvantage to changing them to appropriate `error`s? In fact, is there
any reason that `undefined` shouldn't be banned from the standard
libraries in favor of `error`?
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5532>
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