Skip to content

Cpphs does not expand macros inside haskell comments #2

Description

@phischu

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions