[Fwd: GHC's CPP and Cabal's unlit]

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Wed Nov 28 06:35:19 EST 2007


-------- Forwarded Message --------
> From: Alistair Bayley <alistair at abayley.org>
> To: glasgow-haskell-users at haskell.org, libraries at haskell.org
> Subject: GHC's CPP and Cabal's unlit
> Date: Wed, 28 Nov 2007 10:59:25 +0000
> 
> I'm doing some testing with GHC 6.6.1 and Cabal 1.3, and I'm trying to
> figure out what happens with CPP and Cabal's unlit.
> 
> I start with file Test.lhs:
> 
> > {-# OPTIONS -fglasgow-exts #-}
> > module Test where
> > main = putStrLn "hello CPP"
> 
> and run command:
>   ghc -E -x hs -cpp Test.lhs -o Test2.lhs
> 
> which gives me Test2.lhs:
> 
> {-# LINE 1 "Test.lhs" #-}
> # 1 "Test.lhs"
> # 1 "<built-in>"
> # 1 "<command line>"
> # 1 "Test.lhs"
> > {-# OPTIONS -fglasgow-exts #-}
> > module Test where
> > main = putStrLn "hello CPP"
> 
> 
> So I'm wondering: where does the {-# LINE #-} comment come from, and
> also the # 1 lines? AFAICT the # 1 lines are ignored by GHC; I can
> compile Test2.lhs without errors. Is there anything in GHC's docs
> about this?
> 
> More puzzling is that the files that Cabal runs through ghc's CPP
> don't get the # n lines, so we end up with something like this:
> 
> {-# LINE 1 "Test.lhs" #-}
> > {-# OPTIONS -fglasgow-exts #-}
> > module Test where
> > main = putStrLn "hello CPP"
> 
> which is not a valid .lhs file, because we have a code line next to a comment.
> 
> I also note in Cabal the haddock command runs CPP before unlit. GHC
> does it the other way around i.e. run unlit first then CPP, and I'm
> wondering if Cabal shouldn't do the same thing?
> 
> Thanks,
> Alistair
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries



More information about the cabal-devel mailing list