Variants of ticket #1200 still cropping up
|Reported by:||rrnewton||Owned by:|
|Type of failure:||None/Unknown||Difficulty:|
|Test Case:||Blocked By:|
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 errors? In fact, is there any reason that undefined shouldn't be banned from the standard libraries in favor of error?