Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cpphs does not expand macros inside haskell comments #2

Open
phischu opened this issue Jun 3, 2014 · 4 comments
Open

Cpphs does not expand macros inside haskell comments #2

phischu opened this issue Jun 3, 2014 · 4 comments

Comments

@phischu
Copy link

phischu commented Jun 3, 2014

The vector package makes use of cpp to abstract over inlining phases.
From "vector.h"

#define PHASE_STREAM [1]
#define PHASE_INNER  [0]

#define INLINE_STREAM INLINE PHASE_STREAM
#define INLINE_INNER  INLINE PHASE_INNER
....

From "Data/Vector/Fusion/Stream/Monadic.hs"

....
#include "vector.h"
....
-- | Attach a 'Size' hint to a 'Stream'
sized :: Stream m a -> Size -> Stream m a
{-# INLINE_STREAM sized #-}
sized (Stream step s _) sz = Stream step s sz
....

But cpphs ignores haskell comments when expanding macros.
From input.txt

#define INLINE_STREAM INLINE [1]
{-# INLINE_STREAM sized #-}
INLINE_STREAM

But

>readFile "input.txt" >>= runCpphs defaultCpphsOptions "input.txt" >>= putStrLn
#line 1 "reproduce.hs"

{-# INLINE_STREAM sized #-}
INLINE [1]
@UnkindPartition
Copy link
Member

I'm not sure whether this should be considered a bug in cpphs or in vector.

@malcolmwallace what do you think?

@malcolmwallace
Copy link

Could be a feature rather than a bug. :-) You can try flipping the option to lex input as Haskell, and lex it as plaintext instead. defaultCpphsOptions{ boolopts = defaultBoolOptions { lang=False }}

@phischu
Copy link
Author

phischu commented Jun 3, 2014

Thank you this indeed solved my problem. I can now parse the vector package. Although this required an unrelated workaround. Should I submit a pull request to change the default behavior in hse-cpp? What would be the impact on the other packages?

@UnkindPartition
Copy link
Member

Yeah, I guess submit a patch and include a comment with a link to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants