Variants of ticket #1200 still cropping up
I see that ticket #1200 (closed) 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
?
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |