
As some of you may remember, I recently released a couple of packages on Hackage. I'd like to also release some example programs using these packages, but I'm not sure of the best way to do this. Do I make the example programs part of the package itself? Do I release a seperate package which just contains the example code? Something else entirely? What's the recommendation here?

On Sat, 8 Aug 2009, Andrew Coppin wrote:
As some of you may remember, I recently released a couple of packages on Hackage. I'd like to also release some example programs using these packages, but I'm not sure of the best way to do this.
Do I make the example programs part of the package itself? Do I release a seperate package which just contains the example code? Something else entirely? What's the recommendation here?
Usually I include the example program in the package, but make its compilation conditional using a Cabal flag like buildExamples. This way, you can build the examples explicitly by cabal install package -fbuildExamples but they won't be build when the package is build as dependent package. See for instance: http://code.haskell.org/gnuplot/gnuplot.cabal

Usually I include the example program in the package, but make its compilation conditional using a Cabal flag like buildExamples.
But then the binaries generated from the example program get installed. I think the poster wants to share the source code, not install a demo. I haven't figure out a way to specify test programs that don't get installed, but are only intended to be built and run within the context of a source distribution. John

John D. Ramsdell wrote:
Usually I include the example program in the package, but make its compilation conditional using a Cabal flag like buildExamples.
But then the binaries generated from the example program get installed. I think the poster wants to share the source code, not install a demo.
But only if the flag is set. The user can simply look at the source code example without installing the program. Another option: test code (or any other source) can easily be included in the source dist by adding them to the "extra-source-files:" line in the .cabal file. I include tests in the pureMD5 package in this manner. Thomas

On Sun, Aug 9, 2009 at 8:15 PM, Thomas
DuBuisson
... Another option: test code (or any other source) can easily be included in the source dist by adding them to the "extra-source-files:" line in the .cabal file.
But then cabal doesn't know how to build binaries from the source files with that option. John

Maybe in addition to having a buildable boolean in a library or executable section, there should be an installable boolean. It would default to true, but when false, the library or executable section is ignored during package installation. John

On 10/08/2009, at 9:29 AM, John D. Ramsdell wrote:
Usually I include the example program in the package, but make its compilation conditional using a Cabal flag like buildExamples.
But then the binaries generated from the example program get installed. I think the poster wants to share the source code, not install a demo.
I haven't figure out a way to specify test programs that don't get installed, but are only intended to be built and run within the context of a source distribution.
Couldn't resist a chance to spruik TBC (Testing By Convention) <http://hackage.haskell.org/package/TBC
- it's a framework Pete Gammie and I are developing to run tests in Haskell.
In addition to a few other neat features like not having to write boilerplate main functions by way of some conventions about how to run tests, it knows enough about Cabal to use the package information etc to link your tests together, and provides a command line tool (tbc) to run your tests and provide a report. If you use it and it's helpful to you, or you have any suggestions for how it could be improved, please let me or Pete know. Cheers Mark

John D. Ramsdell wrote:
Usually I include the example program in the package, but make its compilation conditional using a Cabal flag like buildExamples.
But then the binaries generated from the example program get installed. I think the poster wants to share the source code, not install a demo.
Indeed yes. Example programs that don't really "do" anything exciting, but show you what kind of program structure you need to use and which functions to read up on to get your bearings. Since nobody else seems to have mentioned it yet: Another possibility is to embed [short!] examples into the Haddock documentation. For example, Control.Monad.Reader has several pages of example code at the bottom of the Haddock page. I am ambivilent as to whether this is a good or bad idea...
I haven't figure out a way to specify test programs that don't get installed, but are only intended to be built and run within the context of a source distribution.
Yes, I was going to ask about that too - but that's a seperate question. ;-)

Am Samstag, 8. August 2009 13:29 schrieb Andrew Coppin:
As some of you may remember, I recently released a couple of packages on Hackage. I'd like to also release some example programs using these packages, but I'm not sure of the best way to do this.
Do I make the example programs part of the package itself? Do I release a seperate package which just contains the example code? Something else entirely? What's the recommendation here?
I had to make this decision for Grapefruit, and I decided to put the examples into a separate package named grapefruit-examples. Note that the rest of Grapefruit was already split into several packages with names of the form grapefruit-*. Best wishes, Wolfgang

This seems to me like the kind of thing hackage maintainers should be
giving guidance on (maybe they do already?) so that there is
consistency.
Sorry if this seems too off base, but here I go anyway... I have used
apache IVY for packaging/dependency management in java and I really
like the way it works. They have spent a lot of effort figuring out
how to deal with complex project dependencies. For example they have
organization (eg. "com.sun") and project (eg "javaSDK") concepts that
help to keep the namespace clean. They also have different "profiles"
like "test" or "dist" that you can depend on. Maybe it would be
worthwhile to poke around ivy's docs and see if we want to pull any of
these concepts into cabal/hackage
On Mon, Aug 10, 2009 at 10:04 AM, Wolfgang
Jeltsch
Am Samstag, 8. August 2009 13:29 schrieb Andrew Coppin:
As some of you may remember, I recently released a couple of packages on Hackage. I'd like to also release some example programs using these packages, but I'm not sure of the best way to do this.
Do I make the example programs part of the package itself? Do I release a seperate package which just contains the example code? Something else entirely? What's the recommendation here?
I had to make this decision for Grapefruit, and I decided to put the examples into a separate package named grapefruit-examples. Note that the rest of Grapefruit was already split into several packages with names of the form grapefruit-*.
Best wishes, Wolfgang _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- keithsheppard.name
participants (7)
-
Andrew Coppin
-
Henning Thielemann
-
John D. Ramsdell
-
Keith Sheppard
-
Mark Wotton
-
Thomas DuBuisson
-
Wolfgang Jeltsch