Re: core dumps when making use of IORefs

1999-09-22 Thread Hannah Schroeter

Hello!

On Tue, Sep 14, 1999 at 12:43:11AM -0700, Simon Peyton-Jones wrote:
> > {-# notInline test #-}
> > test :: IORef [a]
> > test = unsafePerformIO $ newIORef []

> > main = do
> > writeIORef test [42]
> > bang <- readIORef test
> > print (bang :: [Char])

> [...]

Hmmm. The type of test should be IORef (forall a.[a]).
So you should be able to put into it only values of type
forall a.[a], nothing more or less specific.

I.e. you should be able to store (and retrieve) any lists of
the form {bot:}[] or {bot:}bot, where {} means zero or more of
that, and bot means anything bottom valued (as bottom is the only
value in forall a.a, from a type theoretic point of view).

Regards, Hannah.



`forall' subtelties (was: Re: core dumps when making use of IORefs)

1999-09-22 Thread Michael Weber

On Wed, Sep 22, 1999 at 00:36:27 +0200, Hannah Schroeter wrote:
> On Tue, Sep 14, 1999 at 12:43:11AM -0700, Simon Peyton-Jones wrote:
> > > {-# notInline test #-}
> > > test :: IORef [a]
> > > test = unsafePerformIO $ newIORef []
> 
> > > main = do
> > > writeIORef test [42]
> > > bang <- readIORef test
> > > print (bang :: [Char])
> 
> Hmmm. The type of test should be IORef (forall a.[a]).
> So you should be able to put into it only values of type
> forall a.[a], nothing more or less specific.

GHC doesn't accept the type `IORef (forall a.[a])':
ghc-test.hs:6: Unexpected forall type: forall a. [a]
Compilation had errors

I also tried `IORef [forall a.a]', which gives:
ghc-test.hs:6: parse error on input `forall'
Compilation had errors

and `IORef [(forall a.a)]', which gives:
ghc-test.hs:6: Unexpected forall type: forall a. a
Compilation had errors

At least, the latter two cases should IMHO be treated equal, so this seems
to be a bug in the parser.

Finally, I tried `forall a.IORef [a]' (as only change), but this is just a
more verbose writing of `IORef [a]' according to Haskell Report#4.1.2 and
GHC-users-guide#5.6. Naturally, the program compiles and dumps core as
before.


Cheers,
Michael
-- 
The First Commandment for Technicians:
Beware the lightening that lurketh in the undischarged capacitor,
lest it cause thee to bounce upon thy buttocks in a most untechnician-like
manner. -- fortune cookie