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 'has

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

2010-12-13 Thread Duncan Coutts
On 1 December 2010 03:54, Michael Snoyman wrote: > On Wed, Dec 1, 2010 at 4:07 AM, Thomas Schilling > 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_ m

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 wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash

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 r

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 GHC<7 or a > different compiler with base-4.3. Since the base package is

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.3 && < 5 >cpp-options: -DGHC7 >else >build-depends: base

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 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 runhaskell, and (unless

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 thi

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 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_ macros for each in > build-depends. > >  2. GHC 6.12.* com

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_ macros for each in build-depends. 2. GHC 6.12.* comes with template-haskell 2.4, so to test for that use: #ifdef MIN_VE

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 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 passed down from

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 wrote: > On Sat, Nov 27, 2010 at 8:38 PM, Jinjing Wang wrote: >> Hi Michael, you are absolutely correct, cabal did set the flags >> automatically. >> >> To sum up, here's what needs to be done: >> >> * ad

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: Wa

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 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 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.3 && < 5 cpp-options: -DGHC7 else

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 wrote: > On Sat, Nov 27, 2010 at 10:59 AM, Jinjing Wang 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 b

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 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, what i

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 wrote: > Thanks Michael, > > So the user shou

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 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

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 automatica

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 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, what is

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 >

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 s

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 enta