[Haskell-cafe] trouble compiling "import GHC.Prim(MutableByteArray#, ....." (building regex-tdfa from darcs) -- what's that # sign doing?

Stefan O'Rear stefanor at cox.net
Fri Aug 17 16:47:57 EDT 2007


On Fri, Aug 17, 2007 at 04:27:29PM -0400, Thomas Hartman wrote:
> trying to compile regex-tdfa, I ran into another issue. (earlier I had a 
> cabal problem but that's resolved.)
> 
> there's a line that won't compile, neither for ghc 6.6.1 nor 6.7 
> 
> import 
> GHC.Prim(MutableByteArray#,RealWorld,Int#,sizeofMutableByteArray#,unsafeCoerce#)
> 
> so the fresh darcs regex tdfa package won't build.
> 
> This line (line 16 below) causes this error for 
> 
>   ghc -e '' RunMutState.hs
> 
> for both ghc 6.1 and 6.7 

There are at least two things going on here.

1. GHC-specific unboxed identifiers have a # in the name.   I think this
   is a relic from back when the only reasonable way to namespace was to
   modify your compiler to add extra identifier characters, and use them
   in all non-portable identifiers.  In any case, you have to enable the
   -fglasgow-exts option (or -XMagicHash in recent 6.7) to allow imports
   of such identifiers.

2. Explicitly importing GHC.Prim has been discouraged for as long as I
   can remember, and GHC HQ has finally made good on the promise to make
   it impossible.  Code which imports it has a bug already, which can be
   fixed by switching to GHC.Exts.  (Why?  GHC.Prim is wired into the
   compiler, while GHC.Exts is a normal Haskell module, so by using
   GHC.Exts you are insulated from questions of what is primitive and
   what is derived but still unportable.  Yes, this does change.)

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070817/7e20d7a3/attachment.bin


More information about the Haskell-Cafe mailing list