Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-12-14 Thread Henning Thielemann
On Mon, 13 Dec 2010, John Meacham wrote: A better plan would be to start depending on 'haskell2010' or 'haskell98' and get rid of explicit dependencies on 'base' altogether. Since those are standardized between compilers. I admit that once in the past I have replaced all dependencies on

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-12-13 Thread John Meacham
A better plan would be to start depending on 'haskell2010' or 'haskell98' and get rid of explicit dependencies on 'base' altogether. Since those are standardized between compilers. John On Tue, Dec 7, 2010 at 6:59 PM, Brandon S Allbery KF8NH allb...@ece.cmu.edu wrote: -BEGIN PGP SIGNED

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-12-13 Thread Duncan Coutts
On 1 December 2010 03:54, Michael Snoyman mich...@snoyman.com wrote: On Wed, Dec 1, 2010 at 4:07 AM, Thomas Schilling nomin...@googlemail.com wrote: I think a nicer way to solve that issue is to use Cabal's MIN_VERSION macros.  1. Add CPP to your extensions.  This will cause cabal to

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-12-07 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/7/10 06:00 , Henning Thielemann wrote: Brandon S Allbery KF8NH wrote: Since the base package is (with good reason) part of the compiler, anyone smart enough to get that to work is smart enough to edit the cabal file. There are good reasons

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-12-05 Thread Henning Thielemann
Jason Dagit schrieb: I see that others have provided answers on here, but another way is to change the check from: if flag(ghc7) build-depends: base = 4.35 cpp-options: -DGHC7 else build-depends: base =

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-12-05 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/5/10 17:05 , Henning Thielemann wrote: Isn't it better to move the dependency on 'base' out of the If block? I mean, someone might succeed to use GHC-7 with base-4.2 or GHC7 or a different compiler with base-4.3. Since the base package is

Re: [Haskell-cafe] Conditional compilation for different versionsof GHC?

2010-12-01 Thread Claus Reinke
This is obviously a personal preference issue, but I try to avoid the Cabal macros since they don't let my code run outside the context of Cabal. I often times like to have a test suite that I can just use with runhaskell, and (unless you can tell me otherwise) I can't run it anymore. Also, I

Re: [Haskell-cafe] Conditional compilation for different versionsof GHC?

2010-12-01 Thread Michael Snoyman
On Wed, Dec 1, 2010 at 6:58 PM, Claus Reinke claus.rei...@talk21.com wrote: This is obviously a personal preference issue, but I try to avoid the Cabal macros since they don't let my code run outside the context of Cabal. I often times like to have a test suite that I can just use with

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-30 Thread Jason Dagit
On Sat, Nov 27, 2010 at 9:59 AM, Jinjing Wang nfjinj...@gmail.com wrote: Thanks Michael, So the user should use `cabal install --flags -ghc7 package-name` to install the package, if I'm not mistaken? Will it work if the package is installed as a dependency? Will the flag environment be

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-30 Thread Thomas Schilling
I think a nicer way to solve that issue is to use Cabal's MIN_VERSION macros. 1. Add CPP to your extensions. This will cause cabal to auto-generate a file with MIN_VERSION_pkg macros for each pkg in build-depends. 2. GHC 6.12.* comes with template-haskell 2.4, so to test for that use: #ifdef

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-30 Thread Michael Snoyman
On Wed, Dec 1, 2010 at 4:07 AM, Thomas Schilling nomin...@googlemail.com wrote: I think a nicer way to solve that issue is to use Cabal's MIN_VERSION macros.  1. Add CPP to your extensions.  This will cause cabal to auto-generate a file with MIN_VERSION_pkg macros for each pkg in

[Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Dear list, From ghc 7.0.1 release notes: The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: quoteType and quoteDec. Some of my code needs to be conditionally compiled to support both version 6 and 7, what is the recommended way to do it? ref: *

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Michael Snoyman
On Sat, Nov 27, 2010 at 6:59 PM, Jinjing Wang nfjinj...@gmail.com wrote: Dear list, From ghc 7.0.1 release notes: The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: quoteType and quoteDec. Some of my code needs to be conditionally compiled to support both version 6 and 7,

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Thanks Michael, So the user should use `cabal install --flags -ghc7 package-name` to install the package, if I'm not mistaken? Will it work if the package is installed as a dependency? Will the flag environment be passed down from the root package? Is there a way to detect GHC version

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Sorry, should be `cabal install --flags=ghc7 package-name`. On Sun, Nov 28, 2010 at 1:59 AM, Jinjing Wang nfjinj...@gmail.com wrote: Thanks Michael, So the user should use `cabal install --flags -ghc7 package-name` to install the package, if I'm not mistaken? Will it work if the package is

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Michael Snoyman
No, the user doesn't need to do anything. By splitting up the base range into pre-7 and post-7, cabal automatically applies the ghc7 flag (and thus adds the GHC7 CPP declaration) as appropriate. Michael On Sat, Nov 27, 2010 at 7:59 PM, Jinjing Wang nfjinj...@gmail.com wrote: Thanks Michael,

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Antoine Latter
On Sat, Nov 27, 2010 at 10:59 AM, Jinjing Wang nfjinj...@gmail.com wrote: Dear list, From ghc 7.0.1 release notes: The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: quoteType and quoteDec. Some of my code needs to be conditionally compiled to support both version 6 and

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Michael Snoyman
On Sat, Nov 27, 2010 at 9:41 PM, Antoine Latter aslat...@gmail.com wrote: On Sat, Nov 27, 2010 at 10:59 AM, Jinjing Wang nfjinj...@gmail.com wrote: Dear list, From ghc 7.0.1 release notes: The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: quoteType and quoteDec. Some of

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Hi Michael, you are absolutely correct, cabal did set the flags automatically. To sum up, here's what needs to be done: * add `flag ghc7` as a field in cabal * add: if flag(ghc7) build-depends: base = 4.35 cpp-options: -DGHC7 else

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Antoine Latter
On Sat, Nov 27, 2010 at 8:38 PM, Jinjing Wang nfjinj...@gmail.com wrote: Hi Michael, you are absolutely correct, cabal did set the flags automatically. To sum up, here's what needs to be done: * add `flag ghc7` as a field in cabal * add:    if flag(ghc7)        build-depends:   base      

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Hi Antoine, Thanks for pointing out, it did work. By using a record style constructor, the code can be made to support both version, something like here = QuasiQuoter { quoteExp = (litE . stringL) , quotePat = (litP . stringL) } in GHC7 there's a warning:

Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Thanks for explaining, it's a nice trick. On Sun, Nov 28, 2010 at 11:16 AM, Antoine Latter aslat...@gmail.com wrote: On Sat, Nov 27, 2010 at 8:38 PM, Jinjing Wang nfjinj...@gmail.com wrote: Hi Michael, you are absolutely correct, cabal did set the flags automatically. To sum up, here's what

RE: [Haskell-cafe] Conditional compilation

2009-03-28 Thread Sittampalam, Ganesh
Robin Green wrote: I am writing some code for citation support in gitit, and all the #ifdefs I'm using to do conditional compilation are a bit tiresome. Suppose you have the requirement that a certain feature of your software be disable-able at compile time, to avoid having to pull in

[Haskell-cafe] Conditional compilation

2009-03-27 Thread Robin Green
I am writing some code for citation support in gitit, and all the #ifdefs I'm using to do conditional compilation are a bit tiresome. Suppose you have the requirement that a certain feature of your software be disable-able at compile time, to avoid having to pull in certain dependencies (which

Re: [Haskell-cafe] Conditional compilation

2009-03-27 Thread Sean Leather
Hi Robin, On Fri, Mar 27, 2009 at 16:13, Robin Green wrote: Suppose you have the requirement that a certain feature of your software be disable-able at compile time, to avoid having to pull in certain dependencies (which may not be available on all platforms). Disabling a feature may entail

Re: [Haskell-cafe] Conditional compilation

2009-03-27 Thread Henning Thielemann
On Fri, 27 Mar 2009, Robin Green wrote: I am writing some code for citation support in gitit, and all the #ifdefs I'm using to do conditional compilation are a bit tiresome. I live well without CPP in Haskell. When I need conditional compilation I create two directories with modules of the

[Haskell-cafe] Conditional compilation of Setup.hs

2007-07-31 Thread Bayley, Alistair
I'd like to add a #ifdef to Takusen's Setup.hs, so that we can have a single source file that will compile with ghc-6.6 and ghc-6.6.1. With ghc-6.6 and Cabal-1.1.6.1 we use splitFileName and joinPaths from Distribution.Compat.FilePath. With ghc-6.6.1 (which includes Cabal-1.1.6.2) these have been