Problem CPP'ifying XSelection.hs

So per a suggestion from sjanssen, I was refactoring my XSelection.hs to optionally use the 'decode' from utf8-string. (When I originally was writing it, utf8-string wasn't even optionally available, so I had copied in the decode definition.) I finished editing, and everything looked dandy, but everytime I compiled, or loaded into GHCi (with :set -DUTF8), it fails to compile! And it fails to compile in a way that really perplexes me: Could not find module `Codec.Binary': Use -v to see a list of the files searched for. Line 34 reads: import Codec.Binary.UTF8.String (decode) Note that the two lines disagree on what is being imported... I tried reinstalling utf8-string and X11-xft, thinking perhaps that was the problem, but that is not it. I can load utf8-string modules fine in GHCi; I can swap out that import line for 'import Codec.Binary.Anythingelse', but the moment I use .Utf8.*, it fails. And I've looked over my changes several times, but it looks to me to be the same as the CPP usage in Fonts.hsc, for example; and if -DUTF8 isn't set, it works fine. I am a little stumped. I can't darcs send it because I don't know if the code is broken or not - it could just be my system. Find the patch attached. -- gwern Bluebird 5707 Kosovo Zemin XM Guppy Internet NVD ABC SGI

On 2008 Sep 20, at 11:33, Gwern Branwen wrote:
I finished editing, and everything looked dandy, but everytime I compiled, or loaded into GHCi (with :set -DUTF8), it fails to compile! And it fails to compile in a way that really perplexes me:
Could not find module `Codec.Binary': Use -v to see a list of the files searched for.
Line 34 reads:
import Codec.Binary.UTF8.String (decode)
The "UTF8" in that import is being converted to "1", because cpp sees "UTF8" as the macro you -D-d. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On 2008.09.20 12:28:24 -0400, "Brandon S. Allbery KF8NH"
On 2008 Sep 20, at 11:33, Gwern Branwen wrote:
I finished editing, and everything looked dandy, but everytime I compiled, or loaded into GHCi (with :set -DUTF8), it fails to compile! And it fails to compile in a way that really perplexes me:
Could not find module `Codec.Binary': Use -v to see a list of the files searched for.
Line 34 reads:
import Codec.Binary.UTF8.String (decode)
The "UTF8" in that import is being converted to "1", because cpp sees "UTF8" as the macro you -D-d.
-- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com
I don't entirely see, but what can I do? I have to import from UTF8.String because that's where decode is, and the UTF8 CPP flag is out of my hands as it is defined elsewhere than XSelection.hs. Also, I'm not sure that's the problem. Fonts.hsc uses the UTF8 flag, and it imports from Codec.Binary.UTF8.String as well; and yet, I've never seen any such compile error with it. -- gwern CIDA Wireless CID Ti president NIMA E.O.D. Sugar Peking of

On Sat, Sep 20, 2008 at 11:33:43AM -0400, Gwern Branwen wrote:
I finished editing, and everything looked dandy, but everytime I compiled, or loaded into GHCi (with :set -DUTF8), it fails to compile! And it fails to compile in a way that really perplexes me:
Wild guess here, but perhaps it is going against a version of XSelection.hs compiled without -DUTF8? In other words, did you call Setup.lhs configure -f with_utf8?

On 2008.09.20 15:52:43 -0700, Devin Mullins
On Sat, Sep 20, 2008 at 11:33:43AM -0400, Gwern Branwen wrote:
I finished editing, and everything looked dandy, but everytime I compiled, or loaded into GHCi (with :set -DUTF8), it fails to compile! And it fails to compile in a way that really perplexes me:
Wild guess here, but perhaps it is going against a version of XSelection.hs compiled without -DUTF8? In other words, did you call Setup.lhs configure -f with_utf8?
I've watched the configure; the utf8 is True (as is the default). Presumably if the flag weren't True, were False, then the codec import would never be reached, it would just reveal the in-file definition of 'decode'. So I don't think it has to do with the configure invocation unless I've missed something. -- gwern New cocaine RDI nonac CTU NAVCM TACSAT Computer Secert WASS

On Sat, Sep 20, 2008 at 11:33:43AM -0400, Gwern Branwen wrote:
So per a suggestion from sjanssen, I was refactoring my XSelection.hs to optionally use the 'decode' from utf8-string. (When I originally was writing it, utf8-string wasn't even optionally available, so I had copied in the decode definition.)
I finished editing, and everything looked dandy, but everytime I compiled, or loaded into GHCi (with :set -DUTF8), it fails to compile! And it fails to compile in a way that really perplexes me:
Could not find module `Codec.Binary': Use -v to see a list of the files searched for.
Line 34 reads:
import Codec.Binary.UTF8.String (decode) Note that the two lines disagree on what is being imported...
I tried reinstalling utf8-string and X11-xft, thinking perhaps that was the problem, but that is not it. I can load utf8-string modules fine in GHCi; I can swap out that import line for 'import Codec.Binary.Anythingelse', but the moment I use .Utf8.*, it fails. And I've looked over my changes several times, but it looks to me to be the same as the CPP usage in Fonts.hsc, for example; and if -DUTF8 isn't set, it works fine.
I am a little stumped. I can't darcs send it because I don't know if the code is broken or not - it could just be my system. Find the patch attached.
-- gwern Bluebird 5707 Kosovo Zemin XM Guppy Internet NVD ABC SGI
I believe that the UTF8 is being replaced by "1", which breaks the import statement. This seems to work in Font.hsc, I suspect that is because hsc2hs uses a different C pre-processor. The solution is to change our defined name from "UTF8" to something else ("USE_UTF8" for example). Be sure to update all other files that use the "UTF8" macro. Cheers, Spencer Janssen
participants (4)
-
Brandon S. Allbery KF8NH
-
Devin Mullins
-
Gwern Branwen
-
Spencer Janssen