Nick Eby wrote:
> In trying to compile the Random library from the hugs98 distribution
> i got the following error:
> Random.hs:205: parse error on input `::'
> Line 205 reads:
> primitive getRandomSeed :: IO Integer
> 
> I don't see a syntactic error in this line.

I do.   :-)

> Does ghc have a problem with the 'primitive' declaration? [...]

Exactly. In GHC (and probably already in NHC, too. Malcolm?) you
have to write

   foreign import unsafe getRandomSeed :: IO Int

A few remarks:

   * `unsafe' is not necessary, but improves performance, telling
     GHC that getRandomSeed won't re-enter Haskell-land before it
     has finished (less state to save/restore in the RTS).

   * You can't return `Integer' in GHC, only `Int'. This is a
     deliberate design decision, because only primitive types should
     be handled by the FFI. Integers are not primitive at all, see
     e.g. libgmp.

   * Obvious, but easily forgotten: Don't forget -fglasgow-exts and
     link with the object file containing getRandomSeed (which you
     probably have to rip off the Hugs98 sources).

Cheers,
   Sven
-- 
Sven Panne                                        Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik                     FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen              Oettingenstr. 67
mailto:[EMAIL PROTECTED]            D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne

Reply via email to