Hello Bug Hunters,
The following program (rather condensed as it comes from something
much larger), crashes the compiler. I am using ghc-2.05 on a Solaris
box, with one or two patches(including the WwLib one which Simon gave
me, but this error occured before applying this patch).
It seems to be some rather subtle dependency problem. Compiling with
-O solves the problem, compiling with ghc -c Foo.lhs should highlight
it. The error message is appended below the file. What are the new
"discarding polymorphic case" warnings about?
If you change any line in reallyFlatten, the program compiles fine.
Likewise if you change the type of LinearCode to Int!
Jon
> -- SNIP START
> module Foo where
> import Array
> import Monad
> reallyFlatten :: Int -> Int -> Interpreter ()
> reallyFlatten x t
> = do
> let f = goo x
> out $ show x
> setIStatus (IFlattened f f)
> return ()
> goo :: Int -> LinearCode
> goo = \x -> listArray (0,1) []
%---------------------------------------------------------------------
> type LinearCode = Array Int Int
> data InterpStatus = IFlattened !LinearCode !LinearCode
> data SM = SM { interpStatus :: InterpStatus }
> initialState = SM { interpStatus = IFlattened undefined undefined }
> newtype Interpreter a = RepInterp ((SM,Int) -> IO (Error ((SM,Int),a)))
> getRepInterp (RepInterp a ) = a
> instance Functor Interpreter where
> map f (RepInterp intp )
> = RepInterp (\s -> case intp s of
> g -> g >>= \q ->
> case q of
> Error mes -> return $ Error mes
> Ok (s',a') -> return $ Ok (s',f a'))
> instance Monad Interpreter where
> return x = RepInterp (\s -> return (Ok (s,x)))
> (RepInterp intp) >>= g
> = RepInterp(\s -> case intp s of
> p -> p >>= \q ->
> case q of
> Error mes -> return $ Error mes
> Ok (s',x') -> getRepInterp (g x') s' )
> instance OutputMonad Interpreter where
> out s = RepInterp (\st -> putStr s >>
> return (Ok (st,())))
> updateSM :: (SM -> SM) -> Interpreter SM
> updateSM f = RepInterp (\s@(sm,ty) -> return $ Ok ((f sm,ty), sm))
> setIStatus :: InterpStatus -> Interpreter InterpStatus
> setIStatus is = updateSM (\sm -> sm {interpStatus = is}) >>=
> return.interpStatus
> data Error a = Ok a | Error String
>
> class Monad m => OutputMonad m where
> out :: String -> m ()
> instance OutputMonad IO where
> out s = catch (putStr s) (\_ -> fail $userError "Oh MY")
> -- SNIP ENDS
----------------------------------------------------------------------
Warning: discarding polymorphic case: tpl_s2X9
Warning: discarding polymorphic case: tpl_s2Xg
Warning: discarding polymorphic case: Prelude.undefined{-rad,p-} _@_
LinearCode{-r68,x-}
Warning: discarding polymorphic case: Prelude.undefined{-rad,p-} _@_
LinearCode{-r68,x-}
Warning: discarding polymorphic case: f_s3dL
Warning: discarding polymorphic case: tpl_s3dT
panic! (the `impossible' happened):
lookupBindC:no info!
for: tpl_s3dT
(probably: data dependencies broken by an optimisation pass)
static binds for:
$ge_aMu
$gc_aMO
$gb_aOI{n}
$ga_aXZ
$g4_aY1
$g3_aY3
$g5_aY4
$g2_aY7
$g1_aY8
$g8_aY9
$g9_aYc
scsel_OutputMonadPrelBaseMonad{-aYe,x-}
$g6_a1jM
$g7_a1jN
$gf_d1hv
$g0_g0
$gd_gd
interpStatus{-rg,x-}
SM{-rh,x-}{i}
Error{-ri,x-}{i}
Ok{-rj,x-}{i}
goo{-r4j,x-}
updateSM{-r4k,x-}
setIStatus{-r4l,x-}
getRepInterp{-r4m,x-}
initialState{-r4n,x-}
out{-r60,x-}
RepInterp{-r63,x-}{i}
IFlattened{-r66,x-}{i}
$d4{-rYf,x-}
$d3{-rYg,x-}
$d2{-rYh,x-}
$d1{-rYi,x-}
$d8{-rYp,x-}
$d7{-rYq,x-}
$d6{-rYr,x-}
$d5{-rYs,x-}
local binds for:
$x4_s3dL
Please report it as a compiler bug to [EMAIL PROTECTED]