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

Thomas Hartman thomas.hartman at db.com
Fri Aug 17 20:13:55 EDT 2007

Thanks Stefan. I got regex tdfa to compile on 6.7. FWIW, here's a patch, 
generated with darcs whatsnew against a fresh unzip of regex tdfa 0.92

I didn't patch against the darcs head because this uses a "language" 
progma in {-# options #-} in some file*, which ghc 6.7 didn't know what to 
do with, nor I.

*: Text/Regex/TDFA/RunMutState.hs: {-# LANGUAGE CPP #-} (in darcs head, 
which as I said, I did not patch against, rather I patched against 0.92 
downloaded and unzipped.)

If there is a better way than this to send patches please advise, as I 
don't do this terribly often. (Actually I have no idea how to apply the 
below patch... is there a way?)

hunk ./Data/IntMap/CharMap.hs 1
+{-# OPTIONS -XGeneralizedNewtypeDeriving #-}
hunk ./Data/IntMap/EnumMap.hs 1
+{-# OPTIONS -XGeneralizedNewtypeDeriving #-}
hunk ./Data/IntSet/EnumSet.hs 1
+{-# OPTIONS -XGeneralizedNewtypeDeriving #-}
hunk ./Text/Regex/TDFA/ByteString/Lazy.hs 1
-{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -fno-warn-orphans -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/Common.hs 1
-{-# OPTIONS -funbox-strict-fields #-}
+{-# OPTIONS -funbox-strict-fields -XGeneralizedNewtypeDeriving #-}
hunk ./Text/Regex/TDFA/CorePattern.hs 1
+{-# OPTIONS -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/CorePattern.hs 38
+import Data.Monoid
+import Control.Monad
hunk ./Text/Regex/TDFA/RunMutState.hs 1
+{-# OPTIONS -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/String.hs 1
-{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -fno-warn-orphans -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/TDFA.hs 1
+{-# OPTIONS -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/TDFA.hs 12
-import Control.Monad.RWS
+import Control.Monad (mplus)
+--import Control.Monad.RWS
hunk ./Text/Regex/TDFA/TDFA.hs 33
+import Data.Monoid
hunk ./Text/Regex/TDFA/TNFA.hs 1
-{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -fno-warn-orphans -fglasgow-exts #-}
hunk ./Text/Regex/TDFA/Wrap.hs 1
-{-# OPTIONS -fno-warn-orphans #-}
+{-# OPTIONS -fno-warn-orphans -fglasgow-exts #-}
hunk ./Text/Regex/TDFA.hs 42
-                      ,module Text.Regex.TDFA.String
-                      ,module Text.Regex.TDFA.ByteString
-                      ,module Text.Regex.TDFA.ByteString.Lazy
-                      ,module Text.Regex.TDFA.Sequence
+                      --,module Text.Regex.TDFA.String
+                      --,module Text.Regex.TDFA.ByteString
+                      --,module Text.Regex.TDFA.ByteString.Lazy
+                      --,module Text.Regex.TDFA.Sequence
hunk ./regex-tdfa.cabal 16
-Build-Depends:          regex-base >= 0.80, base >= 2.0, parsec, mtl
+Build-Depends:          regex-base >= 0.80, base >= 2.0, parsec, mtl, 
containers, array, bytestring

"Stefan O'Rear" <stefanor at cox.net> 
08/17/2007 04:47 PM

Thomas Hartman/ext/dbcom at DBAmericas
haskell-cafe <haskell-cafe at haskell.org>
Re: [Haskell-cafe] trouble compiling "import GHC.Prim(MutableByteArray#, 
....."  (building regex-tdfa from       darcs) -- what's that # sign 

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 
> 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.)

[attachment "signature.asc" deleted by Thomas Hartman/ext/dbcom] 


This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070817/89f273e0/attachment.htm

More information about the Haskell-Cafe mailing list