Additional functionality using cabal configure flags

Hi everybody, I am looking for the correct way to provide additional functionality using cabal configure flags. Even though the developer faq [1] says that it is not recommended, I don't see any downsides for an executable package. Is it 'not recommended' even for executable packages? If not, then how can I do it? [1]: https://wiki.haskell.org/Cabal/Developer-FAQ -- Regards Sumit Sahrawat

Hi Sumit,
Documentation clearly mentions it is related to API, so don't worry with
executable and feel free to use the flags (still, depending on what are you
doing, flags might not be the best solution).
12 бер. 2015 18:40, користувач "Sumit Sahrawat, Maths & Computing, IIT
(BHU)"
Hi everybody,
I am looking for the correct way to provide additional functionality using cabal configure flags. Even though the developer faq [1] says that it is not recommended, I don't see any downsides for an executable package.
Is it 'not recommended' even for executable packages? If not, then how can I do it?
[1]: https://wiki.haskell.org/Cabal/Developer-FAQ
-- Regards
Sumit Sahrawat
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Hi Konstantine, thanks for the reply
I decide to use flags, but then the trouble is that I will need some
mechanism to flag parts of the code, possibly using the CPP extension.
I wanted to know whether there is a better way. Also, does CPP allow
checking cabal configure flags? The user-guide did not mention such
usecases.
On 13 March 2015 at 02:23, Konstantine Rybnikov
Hi Sumit,
Documentation clearly mentions it is related to API, so don't worry with executable and feel free to use the flags (still, depending on what are you doing, flags might not be the best solution). 12 бер. 2015 18:40, користувач "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
написав: Hi everybody,
I am looking for the correct way to provide additional functionality using cabal configure flags. Even though the developer faq [1] says that it is not recommended, I don't see any downsides for an executable package.
Is it 'not recommended' even for executable packages? If not, then how can I do it?
[1]: https://wiki.haskell.org/Cabal/Developer-FAQ
-- Regards
Sumit Sahrawat
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Regards Sumit Sahrawat

Sumit,
Here's an example:
```
flag production
default: False
Executable Foo
if flag(production)
cpp-options: -DPRODUCTION
```
I should note that while I have this mechanism in my code, I think that
overall it wasn't a good choice, and I'd rather prefer parsing a
command-line argument and passing it through my code in stead of having a
flag like this. It makes code much harder to write, because each usage has
heavy syntax of:
```
#ifdef PRODUCTION
something
#else
somethingElse
#endif
```
while instead you could just write:
```
if production then something else somethingElse
```
On Thu, Mar 12, 2015 at 11:43 PM, Sumit Sahrawat, Maths & Computing, IIT
(BHU)
Hi Konstantine, thanks for the reply
I decide to use flags, but then the trouble is that I will need some mechanism to flag parts of the code, possibly using the CPP extension. I wanted to know whether there is a better way. Also, does CPP allow checking cabal configure flags? The user-guide did not mention such usecases.
On 13 March 2015 at 02:23, Konstantine Rybnikov
wrote: Hi Sumit,
Documentation clearly mentions it is related to API, so don't worry with executable and feel free to use the flags (still, depending on what are you doing, flags might not be the best solution). 12 бер. 2015 18:40, користувач "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
написав: Hi everybody,
I am looking for the correct way to provide additional functionality using cabal configure flags. Even though the developer faq [1] says that it is not recommended, I don't see any downsides for an executable package.
Is it 'not recommended' even for executable packages? If not, then how can I do it?
[1]: https://wiki.haskell.org/Cabal/Developer-FAQ
-- Regards
Sumit Sahrawat
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Regards
Sumit Sahrawat

Thanks. That's just what I needed.
As much as I want to avoid it, it seems that I don't have much choice.
I'm building a calculator-ish repl that also allows plotting. I don't want
the users to have to install gtk and all that stuff if they don't require
it.
I'll try and refactor my code to see what I can do, but that would mean
less extensibility.
I started out with the expression problem, and now I might have to work
against what I built.
On 13 March 2015 at 13:05, Konstantine Rybnikov
Sumit,
Here's an example:
``` flag production default: False
Executable Foo if flag(production) cpp-options: -DPRODUCTION ```
I should note that while I have this mechanism in my code, I think that overall it wasn't a good choice, and I'd rather prefer parsing a command-line argument and passing it through my code in stead of having a flag like this. It makes code much harder to write, because each usage has heavy syntax of:
``` #ifdef PRODUCTION something #else somethingElse #endif ```
while instead you could just write:
``` if production then something else somethingElse ```
On Thu, Mar 12, 2015 at 11:43 PM, Sumit Sahrawat, Maths & Computing, IIT (BHU)
wrote: Hi Konstantine, thanks for the reply
I decide to use flags, but then the trouble is that I will need some mechanism to flag parts of the code, possibly using the CPP extension. I wanted to know whether there is a better way. Also, does CPP allow checking cabal configure flags? The user-guide did not mention such usecases.
On 13 March 2015 at 02:23, Konstantine Rybnikov
wrote: Hi Sumit,
Documentation clearly mentions it is related to API, so don't worry with executable and feel free to use the flags (still, depending on what are you doing, flags might not be the best solution). 12 бер. 2015 18:40, користувач "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
написав: Hi everybody,
I am looking for the correct way to provide additional functionality using cabal configure flags. Even though the developer faq [1] says that it is not recommended, I don't see any downsides for an executable package.
Is it 'not recommended' even for executable packages? If not, then how can I do it?
[1]: https://wiki.haskell.org/Cabal/Developer-FAQ
-- Regards
Sumit Sahrawat
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Regards
Sumit Sahrawat
-- Regards Sumit Sahrawat

In this case flags for gtk plotting support on/off do seem like a normal
choice
On Fri, Mar 13, 2015 at 9:59 AM, Sumit Sahrawat, Maths & Computing, IIT
(BHU)
Thanks. That's just what I needed.
As much as I want to avoid it, it seems that I don't have much choice. I'm building a calculator-ish repl that also allows plotting. I don't want the users to have to install gtk and all that stuff if they don't require it. I'll try and refactor my code to see what I can do, but that would mean less extensibility. I started out with the expression problem, and now I might have to work against what I built.
On 13 March 2015 at 13:05, Konstantine Rybnikov
wrote: Sumit,
Here's an example:
``` flag production default: False
Executable Foo if flag(production) cpp-options: -DPRODUCTION ```
I should note that while I have this mechanism in my code, I think that overall it wasn't a good choice, and I'd rather prefer parsing a command-line argument and passing it through my code in stead of having a flag like this. It makes code much harder to write, because each usage has heavy syntax of:
``` #ifdef PRODUCTION something #else somethingElse #endif ```
while instead you could just write:
``` if production then something else somethingElse ```
On Thu, Mar 12, 2015 at 11:43 PM, Sumit Sahrawat, Maths & Computing, IIT (BHU)
wrote: Hi Konstantine, thanks for the reply
I decide to use flags, but then the trouble is that I will need some mechanism to flag parts of the code, possibly using the CPP extension. I wanted to know whether there is a better way. Also, does CPP allow checking cabal configure flags? The user-guide did not mention such usecases.
On 13 March 2015 at 02:23, Konstantine Rybnikov
wrote: Hi Sumit,
Documentation clearly mentions it is related to API, so don't worry with executable and feel free to use the flags (still, depending on what are you doing, flags might not be the best solution). 12 бер. 2015 18:40, користувач "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
написав: Hi everybody,
I am looking for the correct way to provide additional functionality using cabal configure flags. Even though the developer faq [1] says that it is not recommended, I don't see any downsides for an executable package.
Is it 'not recommended' even for executable packages? If not, then how can I do it?
[1]: https://wiki.haskell.org/Cabal/Developer-FAQ
-- Regards
Sumit Sahrawat
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Regards
Sumit Sahrawat
-- Regards
Sumit Sahrawat
participants (2)
-
Konstantine Rybnikov
-
Sumit Sahrawat, Maths & Computing, IIT (BHU)