Changes between Initial Version and Version 3 of Ticket #37

Show
Ignore:
Timestamp:
10/15/06 08:22:30 (7 years ago)
Author:
ross
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #37

    • Property owner changed from nobody to ross
    • Property status changed from new to assigned
  • Ticket #37 – description

    initial v3  
    11Hi, 
    22 
    3 a few days ago I wrote a program which handles my own integers. Then I  
    4 check my own implementation against the normal Int implementation in Hugs.  
     3a few days ago I wrote a program which handles my own integers. Then I check my own implementation against the normal Int implementation in Hugs.  
    54Thereby I wonder about inequality of Ints which are definitely equal. 
    65 
    7 This is a test program I wrote after I recognized that hugs  
    8 has probably a bug in the inequality check of Ints. 
    9   
     6This is a test program I wrote after I recognized that hugs has probably a bug in the inequality check of Ints. 
     7{{{ 
     8data MInt = Zero | Succ MInt | Pred MInt deriving Show 
    109 
    11   data MInt = Zero | Succ MInt | Pred MInt deriving Show 
     10tn :: Int -> MInt 
     11tn x | x<0 = Pred (tn (x+1)) 
     12tn 0     =  Zero 
     13tn (n+1) = Succ (tn n) 
    1214 
    13   tn :: Int -> MInt 
    14   tn x | x<0 = Pred (tn (x+1)) 
    15   tn 0     =  Zero 
    16   tn (n+1) = Succ (tn n) 
     15ti :: MInt -> Int 
     16ti Zero = 0 
     17ti (Succ x) = 1+(ti x) 
     18ti (Pred x) = (ti x) -1 
    1719 
    18   ti :: MInt -> Int 
    19   ti Zero = 0 
    20   ti (Succ x) = 1+(ti x) 
    21   ti (Pred x) = (ti x) -1 
     20testi :: (MInt -> MInt -> MInt) -> (Int -> Int -> Int) -> Int -> Int -> Bool 
     21testi f g x y = (ti (f (tn x) (tn y))) /= (g x y) 
    2222 
    23   testi :: (MInt -> MInt -> MInt) -> (Int -> Int -> Int) -> Int -> Int -> Bool 
    24   testi f g x y = (ti (f (tn x) (tn y))) /= (g x y) 
     23myMul x y = tn ((ti x) * (ti y)) 
    2524 
    26   myMul x y = tn ((ti x) * (ti y)) 
     25test = [(x,y,ti (myMul (tn x) (tn y)),x * y)| 
     26          x<-[-100..100], 
     27          y<-([-100..(-1)]++[1..100]),(testi myMul (*)  x y) ] 
     28}}} 
     29The list "test" should be empty in any case but unfortunately hugs returns this (copy of the console):  
     30{{{ 
     31__   __ __  __  ____   ___      _________________________________________ 
     32||   || ||  || ||  || ||__      Hugs 98: Based on the Haskell 98 standard 
     33||___|| ||__|| ||__||  __||     Copyright (c) 1994-2003 
     34||---||         ___||           World Wide Web: http://haskell.org/hugs 
     35||   ||                         Report bugs to: hugs-bugs@haskell.org 
     36||   || Version: November 2003  _________________________________________ 
    2737 
    28   test = [(x,y,ti (myMul (tn x) (tn y)),x * y)| 
    29             x<-[-100..100], 
    30             y<-([-100..(-1)]++[1..100]),(testi myMul (*)  x y) ] 
     38Haskell 98 mode: Restart with command line option -98 to enable extensions 
    3139 
    32 the list "test" should be empty in any case  
    33 but unfortunately hugs returns this (copy of the console):  
    34  
    35   __   __ __  __  ____   ___      _________________________________________ 
    36   ||   || ||  || ||  || ||__      Hugs 98: Based on the Haskell 98 standard 
    37   ||___|| ||__|| ||__||  __||     Copyright (c) 1994-2003 
    38   ||---||         ___||           World Wide Web: http://haskell.org/hugs 
    39   ||   ||                         Report bugs to: hugs-bugs@haskell.org 
    40   ||   || Version: November 2003  _________________________________________ 
    41  
    42   Haskell 98 mode: Restart with command line option -98 to enable extensions 
    43  
    44   Type :? for help 
    45   Main> test 
    46   [(-100,80,-8000,-8000),(-100,99,-9900,-9900), 
    47   (-99,58,-5742,-5742),(-99,83,-8217,-8217), 
    48   (-98,71,-6958,-6958),(-98,86,-8428,-8428), 
    49   (-97,46,-4462,-4462),(-97,87,-8439,-8439), 
    50   (-96,76,-7296,-7296),(-95,88,-8360,-8360),(-94,73,-6862,-6862) 
    51   ERROR - Control stack overflow 
    52   Main>  
    53  
    54 I have checked this program with Hugs on different plattforms:  
    55 Gentoo Linux x86 64-Bit and Suse Linux 32-Bit. On both plattforms  
    56 the same bug occurs with different Ints for each run (i.e. the list  
    57 contains different tuples). I have also checked my program with  
     40Type :? for help 
     41Main> test 
     42[(-100,80,-8000,-8000),(-100,99,-9900,-9900), 
     43(-99,58,-5742,-5742),(-99,83,-8217,-8217), 
     44(-98,71,-6958,-6958),(-98,86,-8428,-8428), 
     45(-97,46,-4462,-4462),(-97,87,-8439,-8439), 
     46(-96,76,-7296,-7296),(-95,88,-8360,-8360),(-94,73,-6862,-6862) 
     47ERROR - Control stack overflow 
     48Main>  
     49}}} 
     50I have checked this program with Hugs on different plattforms:  Gentoo Linux x86 64-Bit and Suse Linux 32-Bit. On both platforms  the same bug occurs with different Ints for each run (i.e. the list  contains different tuples). I have also checked my program with  
    5851other Haskell implementations and there it returns an empty list  
    5952as expected.  
     
    6356 
    6457P.S.: We have tested Sep2006 with similar results: 
     58{{{ 
    6559__   __ __  __  ____   ___      _________________________________________ 
    6660||   || ||  || ||  || ||__      Hugs 98: Based on the Haskell 98 standard 
     
    7569Main> :e 
    7670Main> test 
    77 [(-100,90,-9000,-9000),(-98,40,-3920,-3920),(-97,63,-6111,-6111),(-97,69,-6693,-                                                                                                   6693) 
     71[(-100,90,-9000,-9000),(-98,40,-3920,-3920),(-97,63,-6111,-6111),(-97,69,-6693,-6693) 
    7872ERROR - Control stack overflow 
     73}}}