[Haskell-cafe] cpp question
Malcolm Wallace
malcolm.wallace at me.com
Sun Feb 1 22:00:42 UTC 2015
If cpp is troublesome, another workaround might be to persuade ghc to use cpphs, which at least is aware of Haskell syntax.
Regards,
Malcolm (iPhone)
On 1 Feb 2015, at 21:51, Brandon Allbery <allbery.b at gmail.com> wrote:
On Sun, Feb 1, 2015 at 4:42 PM, S. Doaitse Swierstra <doaitse at swierstra.net> wrote:
> With the new version of GHC (7.8.3) I am running into problems with cpp.
>
> The header of one of the files of my uu-parsinglib library reads as follows:
>
> {-# LANGUAGE NoMonomorphismRestriction,
> RankNTypes,
> FlexibleContexts,
> CPP #-}
> #define DEMO(p,i) demo "p" i p
> #define DEMOG(p,i) demo "p" i (mkP (p))
> module Text.ParserCombinators.UU.Demo.MergeAndPermute where
>
> ...
>
> However when I try to compile this file I get error messages like:
>
> Text/ParserCombinators/UU/Demo/Demo.hs:88:17:
> Not in scope: data constructor ‘DEMOG’
(1) ghc is at 7.8.4. I *think* 7.8.4 does slightly better here, but only slightly:
(2) May I guess that Demo.hs line 88 starts with an identifier with a prime in it? GHC 7.8.3 on OS X tries to make clang's cpp behave like gcc's, but does not completely succeed; clang's cpp will ignore macros in what it thinks are quoted strings/chars, so fails when faced with things like
foo' = ... something using a cpp macro here ...
One workaround is to install ghc from MacPorts (forces gcc's cpp) or the github ghcformacosx repo (which I think is Homebrew-based? so it depends on how much you like code with no error checking to speak of and curl-pipe-sh "hack me please" installation).
7.8.4 may also provide some way to point cpp to "gcc --traditional -E". Long term, we need to move away from using a C preprocessor for Haskell code; there are no guarantees that it won't try to enforce C syntax on you, like clang's does.
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20150201/55ec7e38/attachment.html>
More information about the Haskell-Cafe
mailing list