Dear Glasgow-Wizards,

my first experiment with second-order types failed. The following piece
of code causes ghc to panic.

===============================================================================

> module SOL                    (  module SOL  )
> where

> import GlaExts

> data SeqView t a              =  Null
>                               |  Cons a (t a)

> class PriorityQueue q where
>     empty                     :: (Ord a) => q a
>     single                    :: (Ord a) => a -> q a
>     insert                    :: (Ord a) => a -> q a -> q a
>     meld                      :: (Ord a) => q a -> q a -> q a
>     splitMin                  :: (Ord a) => q a -> SeqView q a
>     insert a q                =  single a `meld` q

> toOrderedList q               =  case splitMin q of
>    Null                       -> []
>    Cons a q                   -> a : toOrderedList q
> insertMany x q                =  foldr insert q x
> pqSort q x                    =  toOrderedList (insertMany x q)

> check                         :: (PriorityQueue q) => (Ord a => q a) -> IO ()
> check empty                   =  do
>     putStr "*** sorting\n"
>     out (pqSort empty [1 .. 99])
>     out (pqSort empty [1.0, 1.1 ..99.9])

> out                           :: (Num a) => [a] -> IO ()
> out x | sum x == 0            =  putStr "ok\n"
>       | otherwise             =  putStr "ok\n"

===============================================================================

I'd be interested to hear whether the code is ok or I'm doing something
foolish. [Second-order types appear to be of use for testing abstract
data types.]

Ralf

P.S.: Looking at verbose output I was a bit worried to see that the
compiler proper has version number 2.03. Is that ok?

================================================================================

jod 144> ghc -fglasgow-exts -c SOL.lhs -v
The Glorious Glasgow Haskell Compilation System, version 2.04, patchlevel 0

literate pre-processor:
        echo '#line 1 "SOL.lhs"' > /tmp/ghc1812.lpp && 
/home/III/a/ralf/FP/ghc-2.04/lib/unlit  SOL.lhs -  >> /tmp/ghc1812.lpp

real        0.0
user        0.0
sys         0.0

Effective command line: -i/home/III/a/ralf/TBoA/GHC/Import 
-L/home/III/a/ralf/TBoA/GHC/lib -lbn -fglasgow-exts -c -v

Ineffective C pre-processor:
        echo '#line 1 "SOL.lhs"' > /tmp/ghc1812.cpp && cat /tmp/ghc1812.lpp >> 
/tmp/ghc1812.cpp

real        0.0
user        0.0
sys         0.0
ghc-2.04:compile:Output file SOL.o doesn't exist
ghc-2.04:compile:Interface file SOL.hi doesn't exist
ghc-2.04:recompile:Input file SOL.lhs newer than SOL.o

Haskell compiler:
        /home/III/a/ralf/FP/ghc-2.04/lib/hsc ,-N ,-W ,/tmp/ghc1812.cpp  -fglasgow-exts 
-fignore-interface-pragmas -fomit-interface-pragmas -fsimplify \(  
-ffloat-lets-exposing-whnf -ffloat-primops-ok -fcase-of-case -freuse-con 
-fpedantic-bottoms -fsimpl-uf-use-threshold3 -fmax-simplifier-iterations4 \)   
-himap=/home/III/a/ralf/TBoA/GHC/Import%.hi:.%.hi:/home/III/a/ralf/FP/ghc-2.04/lib/imports%.hi
   -v -hifile=/tmp/ghc1812.hi -S=/tmp/ghc1812.s +RTS -H6000000 -K1000000


================================================================================
Glasgow Haskell Compiler, version 2.03, for Haskell 1.4


zonkIdOcc: empty_r3T

zonkIdOcc: empty_r3T

panic! (the `impossible' happened):
        lookupBindC:no info!
for: empty_r3T
(probably: data dependencies broken by an optimisation pass)
static binds for:
enumFromTo_a12f
>>=_a12h
enumFromThenTo_a12i
lit_a12j
lit_a12l
lit_a12n
fromRational_a12o
lit_a12p
lit_a12r
fromInt_a12s
out_a12t
out_a12u
Cons{-re,x-}{i}
Null{-rf,x-}{i}
out{-r3A,x-}
pqSort{-r3B,x-}
insertMany{-r3C,x-}
toOrderedList{-r3D,x-}
splitMin{-r4n,x-}
meld{-r4o,x-}
insert{-r4p,x-}
single{-r4q,x-}
empty{-r4r,x-}
$msplitMin{-rId,x-}
$mmeld{-rIe,x-}
$minsert{-rIf,x-}
$msingle{-rIg,x-}
$mempty{-rIh,x-}
$d1{-r14w,x-}
nrlit_s2QP
nrlit_s2QQ
nrlit_s2QR
nrlit_s2QS
nrlit_s2QT
nrlit_s2QU
nrlit_s2QV
nrlit_s2QW
nrlit_s2QX
nrlit_s2QY
nrlit_s2QZ
nrlit_s2R0
nrlit_s2R1
nrlit_s2R2
local binds for:

Please report it as a compiler bug to [EMAIL PROTECTED]


real       10.0
user        3.0
sys         0.2
deleting... /tmp/ghc1812.hi /tmp/ghc1812.s

rm -f /tmp/ghc1812*

Reply via email to