Mysterious type error with Glasgow Haskell

George Russell ger at tzi.de
Thu Oct 18 10:54:49 EDT 2001


Hello Glasgow hackers (cc'd to both Simons as the mailing list will complain that this
bug report is too big).

If you don't redefine the (-) operator, then

   minus :: Int -> Int -> Int
   minus = (-)
should work, shouldn't it?  Also it should be equivalent to
   minus :: Int -> Int -> Int
   minus a b = a + (-1) * b

The attached bzip2 file contains (1) a lot of .hi files; (2) a file SimpleForm.hs.
Compiling it with ghc5.02 on Sparc/Solaris, with the following command line:

/usr/local/pub-bkb/ghc/ghc-latest/bin/ghc -c toolkit/SimpleForm.hs -package concurrent -package data -package net -package posix -package text -package util -package lang -i.:packer:resources:canvasitems:kernel:containers:menuitems:toolkit:components:toplevel:widgets:devices:textitems:tix:/home/ger/uni/util:/home/ger/uni/events:/home/ger/uni/reactor:/home/ger/uni/server:/home/ger/uni/htk:/home/ger/uni/davinci:/home/ger/uni/graphs:/home/ger/uni/tools:/home/ger/uni/cvs:/home/ger/uni/types -fglasgow-exts -fallow-overlapping-instances -fallow-undecidable-instances -cpp -ddump-hi-diffs -H25M -recomp -fwarn-deprecations -Onot -DDEBUG -Onot -H30M -fasm 

gives an error:

toolkit/SimpleForm.hs:379:
    Couldn't match `Int' against `Radio x'
        Expected type: Int -> Int -> Int
        Inferred type: Int -> Int -> Radio x
    In the definition of `minus': (-)

However if you go to line 379, comment out the line "minus = (-)" and
decomment the next line to give "minus a b = a + (-1) * b" the error message
magically disappears and it goes through the compiler.

Am I somehow mistaken, or is this a bug in GHC?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.tar.bz2
Type: application/octet-stream
Size: 63525 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/glasgow-haskell-bugs/attachments/20011018/653f1e1e/bug.tar.obj


More information about the Glasgow-haskell-bugs mailing list