fixST bug in win32.

Ulf Norell d98ulf@dtek.chalmers.se
Mon, 3 Dec 2001 12:48:16 +0100 (MET)


Hi.

Short story
-----------

fixST does not work in Win32 implementation.

Hugs version
------------

I installed hugs from the Windows Installer package found at

http://www.cse.ogi.edu/PacSoft/projects/Hugs/downloads/hugs98-Feb2001.msi

The same problem seems to be present also in the February 2000 release.

Specs
-----

I am running Windows 2000 Professional (Service Pack 2) on an Athlon
Thunderbird machine.

Details
-------

When using (strict) ST i get the following:

ST> runST (fixST (\_ -> return 1))
Show_default_show (Make.Show (Show_default_show (Make.Show ({Interrupted!}

ST> $$
()
ST> $$

Program error: {_Gc Black Hole}

ST> $$
()
ST> $$
()
ST> $$
1
ST> $$

Unexpected signal

C:\Source\Haskell>

It is also possible to get a control stack overflow. Another fascinating
example is the following:

funny = do ones <- fixST (\xs -> return (1:xs))
           return (take 10 ones)

Main> runST funny

Program error: Prelude.take: negative argument

Main>

After doing this a few times you get an Unexpected signal.

The LazyST module is a little more well-behaved (?). Instead of the
unexpected signal you get control stack overflow in the first example,
and the second example always gives the program error.

If you define the above examples as functions (non-updatable)

test1 _ = fixST (\_ -> return 1)
funny _ = do xs <- fixST (\xs -> return (1:xs))
             return (take 10 xs)

Main> runST (test1 ())
1
Main> runST (funny ())

Program error: Prelude.take: negative argument

The first example works while the second still gives an error. Now (of
course) you get the same result every time.

If you redefine funny using ($) in the fixST application it works a little
better:

funny' _ = do xs <- fixST $ \xs -> return (1:xs)
              return (take 10 xs)

Main> runST (funny' ())
[1
Program error: Prelude.take: negative argument

Best Regards
Ulf Norell

 /----------------\ /-----------------------\
( Ulf Norell       | 031-18 68 74            )
( Uppstigen 108-21 | 073-676 40 54           )
( 412 80 Göteborg  | d98ulf@dtek.chalmers.se )
 \----------------/ \-----------------------/