#80: A curious stack overflow problem

View: New views
2 Messages — Rating Filter:   Alert me  

#80: A curious stack overflow problem

by GHC-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

#80: A curious stack overflow problem
--------------------+-------------------------------------------------------
 Reporter:  guest   |       Owner:  nobody
     Type:  defect  |      Status:  new  
 Priority:  major   |   Milestone:        
Component:  hugs    |     Version:  200609
 Keywords:          |  
--------------------+-------------------------------------------------------
 Suppose I define

 > natmin :: [Int] -> Int
 > natmin = foldr1 min
 >  where min x y = if x==0 || x<=y then x else y

 I would expect the same behaviour from

   natmin ([1..10000] ++ [0..])

 as from

   or ([False | i <- [1..10000]] ++ [True | i <- [1..]])

 But the first gives stack overflow, and the second doesn't.

 The problem does not exist with GHCi.

 Richard Bird
 bird@...

--
Ticket URL: <http://hackage.haskell.org/trac/hugs/ticket/80>
Hugs <http://www.haskell.org/hugs/>
Hugs 98, an interpreter for Haskell
_______________________________________________
Hugs-Bugs mailing list
Hugs-Bugs@...
http://www.haskell.org/mailman/listinfo/hugs-bugs

Re: #80: A curious stack overflow problem

by GHC-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

#80: A curious stack overflow problem
----------------------+-----------------------------------------------------
  Reporter:  guest    |       Owner:  nobody
      Type:  defect   |      Status:  closed
  Priority:  major    |   Milestone:        
 Component:  hugs     |     Version:  200609
Resolution:  invalid  |    Keywords:        
----------------------+-----------------------------------------------------
Changes (by ross):

  * status:  new => closed
  * resolution:  => invalid

Comment:

 The behaviour is standard outermost evaluation, driven by the different
 properties of min and (||).  The same thing happens with ghci, if you make
 the first list a bit longer.  (The infinite lists make no difference:
 singleton lists [1] or [True] give the same effect.)

--
Ticket URL: <http://hackage.haskell.org/trac/hugs/ticket/80#comment:1>
Hugs <http://www.haskell.org/hugs/>
Hugs 98, an interpreter for Haskell
_______________________________________________
Hugs-Bugs mailing list
Hugs-Bugs@...
http://www.haskell.org/mailman/listinfo/hugs-bugs
LightInTheBox - Buy quality products at wholesale price!