
I have a script I'm using to generate some Haskell code for a library. How do I specify this flow in the cabal setup file? Would someone point me to a relevant library I can reference as an example? -Tom

Hi Tom This will the job for a UserHooks - probably preBuild? - see Distribution.Simple.UserHooks. postConf - Hook to run after configure command preBuild - Hook to run before build command. Second arg indicates verbosity level. buildHook - Over-ride this hook to get different behaviour during build. lhs2Tex uses user hooks extensively. If that's too complicated, my own library Wumpus-Core uses a preSDist hook in Setup.hs to make sure I've bumped the version number before I ship the library. Best wishes Stephen

On Mon, Jul 19, 2010 at 11:54 AM, Stephen Tetley
Hi Tom
This will the job for a UserHooks - probably preBuild? - see Distribution.Simple.UserHooks.
postConf - Hook to run after configure command preBuild - Hook to run before build command. Second arg indicates verbosity level. buildHook - Over-ride this hook to get different behaviour during build.
Thanks. I tried this, but it appears cabal-install ignores the Setup.hs file. The only way I could get it to take is if I run 'runhaskell Setup.hs configure' directly. I always assumed cabal-install runs Setup.hs under the hood, but apparently not. Why is this?

On Tue, Jul 20, 2010 at 8:50 PM, Tom Hawkins
Thanks. I tried this, but it appears cabal-install ignores the Setup.hs file. The only way I could get it to take is if I run 'runhaskell Setup.hs configure' directly. I always assumed cabal-install runs Setup.hs under the hood, but apparently not. Why is this?
I believe you must set Build-type: Custom in your cabal file to use user hooks in Setup.hs. I don't fully understand the implications of using Custom, though. --Rogan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Wed, Jul 21, 2010 at 04:53, Rogan Creswick
On Tue, Jul 20, 2010 at 8:50 PM, Tom Hawkins
wrote: Thanks. I tried this, but it appears cabal-install ignores the Setup.hs file. The only way I could get it to take is if I run 'runhaskell Setup.hs configure' directly. I always assumed cabal-install runs Setup.hs under the hood, but apparently not. Why is this?
I believe you must set
Build-type: Custom
in your cabal file to use user hooks in Setup.hs. I don't fully understand the implications of using Custom, though.
I am successfully using hooks with the following in my .cabal file: Build-Type : Simple and my main in Setup.hs looks like this: main = defaultMainWithHooks $ simpleUserHooks { cleanHook = profileClean , runTests = runTestsBuild } /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

On Wed, Jul 21, 2010 at 3:00 AM, Magnus Therning
I am successfully using hooks with the following in my .cabal file:
Build-Type : Simple
and my main in Setup.hs looks like this:
main = defaultMainWithHooks $ simpleUserHooks { cleanHook = profileClean , runTests = runTestsBuild }
I've been unable to reproduce this -- flipping the build type to Custom has been necessary in every configuration I've tried. I'd like to see what I'm doing differently -- is this used in a publicly available package I could take a look at? Thanks! Rogan

On Wed, Jul 21, 2010 at 17:43, Rogan Creswick
On Wed, Jul 21, 2010 at 3:00 AM, Magnus Therning
wrote: I am successfully using hooks with the following in my .cabal file:
Build-Type : Simple
and my main in Setup.hs looks like this:
main = defaultMainWithHooks $ simpleUserHooks { cleanHook = profileClean , runTests = runTestsBuild }
I've been unable to reproduce this -- flipping the build type to Custom has been necessary in every configuration I've tried. I'd like to see what I'm doing differently -- is this used in a publicly available package I could take a look at?
It's not ready to be made public yet, but I put together the following example: % cat test.cabal Name : test Version : 0.0.0 License : GPL Author : Magnus Therning Maintainer : magnus@therning.org Copyright : Magnus Therning, 2009 Build-Type : Simple Cabal-Version : >= 1.2 Executable test Main-Is : Main.hs Build-Depends : base >= 4.2.0 && < 4.3 % cat Setup.hs #! /usr/bin/env runhaskell import Distribution.Simple main = defaultMainWithHooks $ simpleUserHooks { cleanHook = profileClean } profileClean pd v uh cf = do (cleanHook simpleUserHooks) pd v uh cf putStrLn "** in hook" % ./Setup.hs configure Configuring test-0.0.0... % ./Setup.hs clean cleaning... ** in hook Could it be a difference in versions? % ghc --version The Glorious Glasgow Haskell Compilation System, version 6.12.1 % ghc-pkg list | grep Cabal Cabal-1.8.0.2 /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

On Wed, Jul 21, 2010 at 09:43:16AM -0700, Rogan Creswick wrote:
On Wed, Jul 21, 2010 at 3:00 AM, Magnus Therning
wrote: I am successfully using hooks with the following in my .cabal file:
Build-Type : Simple
I've been unable to reproduce this -- flipping the build type to Custom has been necessary in every configuration I've tried. I'd like to see what I'm doing differently -- is this used in a publicly available package I could take a look at?
Magnus is building by directly running the Setup.hs himself, which ignores the Build-Type. To get cabal-install to use his Setup.hs, the Build-Type must be set to Custom.

On Thu, Jul 22, 2010 at 10:59, Ross Paterson
On Wed, Jul 21, 2010 at 09:43:16AM -0700, Rogan Creswick wrote:
On Wed, Jul 21, 2010 at 3:00 AM, Magnus Therning
wrote: I am successfully using hooks with the following in my .cabal file:
Build-Type : Simple
I've been unable to reproduce this -- flipping the build type to Custom has been necessary in every configuration I've tried. I'd like to see what I'm doing differently -- is this used in a publicly available package I could take a look at?
Magnus is building by directly running the Setup.hs himself, which ignores the Build-Type. To get cabal-install to use his Setup.hs, the Build-Type must be set to Custom.
Oh, why*2? Why is the header there if it's not used by Cabal, and why does cabal care? Cheers, M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

On Thu, Jul 22, 2010 at 11:31:21AM +0100, Magnus Therning wrote:
On Thu, Jul 22, 2010 at 10:59, Ross Paterson
wrote: Magnus is building by directly running the Setup.hs himself, which ignores the Build-Type. To get cabal-install to use his Setup.hs, the Build-Type must be set to Custom.
Oh, why*2?
Why is the header there if it's not used by Cabal, and why does cabal care?
The field allows cabal to avoid compiling the Setup.hs in this case. It might also be used by other tools, e.g. one might only trust Simple packages. Not all fields are used by all tools, and several of them do not affect the operation of the library (e.g. Home-page).

On Thu, Jul 22, 2010 at 11:52, Ross Paterson
On Thu, Jul 22, 2010 at 11:31:21AM +0100, Magnus Therning wrote:
On Thu, Jul 22, 2010 at 10:59, Ross Paterson
wrote: Magnus is building by directly running the Setup.hs himself, which ignores the Build-Type. To get cabal-install to use his Setup.hs, the Build-Type must be set to Custom.
Oh, why*2?
Why is the header there if it's not used by Cabal, and why does cabal care?
The field allows cabal to avoid compiling the Setup.hs in this case. It might also be used by other tools, e.g. one might only trust Simple packages. Not all fields are used by all tools, and several of them do not affect the operation of the library (e.g. Home-page).
All right, so why would cabal want to avoid compiling the Setup.hs? Of course this behaviour of cabal's means that I in the future will use *Custom* all the time, since I otherwise have to remember this surprising feature of a tool I never use. Is there any reason *not* to do this? Cheers, M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

Magnus Therning wrote:
On Thu, Jul 22, 2010 at 11:52, Ross Paterson
wrote: On Thu, Jul 22, 2010 at 10:59, Ross Paterson
wrote: Magnus is building by directly running the Setup.hs himself, which ignores the Build-Type. To get cabal-install to use his Setup.hs, the Build-Type must be set to Custom. Oh, why*2?
Why is the header there if it's not used by Cabal, and why does cabal care? The field allows cabal to avoid compiling the Setup.hs in this case. It might also be used by other tools, e.g. one might only trust Simple
On Thu, Jul 22, 2010 at 11:31:21AM +0100, Magnus Therning wrote: packages. Not all fields are used by all tools, and several of them do not affect the operation of the library (e.g. Home-page).
All right, so why would cabal want to avoid compiling the Setup.hs?
Of course this behaviour of cabal's means that I in the future will use *Custom* all the time, since I otherwise have to remember this surprising feature of a tool I never use. Is there any reason *not* to do this?
The main reason I could think of to avoid compiling it is for performance reasons. I'm not sure how compelling that is, but... As for why not to always use Custom, as mentioned there are cabal-aware tools out there besides cabal-install. For these other tools, there is a big difference between Simple and Custom. With Simple we (ideally) already know all the semantics of what Setup.hs does, and so we can wire that into our tools. With Custom we're forced into the position of doing Haskell source analysis since we now have to discover the semantics of an arbitrary Turing machine. That's a very high wall to climb if you're just wanting to write a simple tool for doing some kind of package analysis. (I don't think the behavior is surprising since I interpret Simple to mean that the Setup.hs file is unused/optional. Though clearly YMMV) -- Live well, ~wren

On Fri, Jul 23, 2010 at 12:33 PM, wren ng thornton
Magnus Therning wrote:
On Thu, Jul 22, 2010 at 11:52, Ross Paterson
wrote: On Thu, Jul 22, 2010 at 11:31:21AM +0100, Magnus Therning wrote:
On Thu, Jul 22, 2010 at 10:59, Ross Paterson
wrote: Magnus is building by directly running the Setup.hs himself, which ignores the Build-Type. To get cabal-install to use his Setup.hs, the Build-Type must be set to Custom.
Oh, why*2?
Why is the header there if it's not used by Cabal, and why does cabal care?
The field allows cabal to avoid compiling the Setup.hs in this case. It might also be used by other tools, e.g. one might only trust Simple packages. Not all fields are used by all tools, and several of them do not affect the operation of the library (e.g. Home-page).
All right, so why would cabal want to avoid compiling the Setup.hs?
Of course this behaviour of cabal's means that I in the future will use *Custom* all the time, since I otherwise have to remember this surprising feature of a tool I never use. Is there any reason *not* to do this?
The main reason I could think of to avoid compiling it is for performance reasons. I'm not sure how compelling that is, but...
As for why not to always use Custom, as mentioned there are cabal-aware tools out there besides cabal-install. For these other tools, there is a big difference between Simple and Custom. With Simple we (ideally) already know all the semantics of what Setup.hs does, and so we can wire that into our tools. With Custom we're forced into the position of doing Haskell source analysis since we now have to discover the semantics of an arbitrary Turing machine. That's a very high wall to climb if you're just wanting to write a simple tool for doing some kind of package analysis.
(I don't think the behavior is surprising since I interpret Simple to mean that the Setup.hs file is unused/optional. Though clearly YMMV)
Ah, this clears up one of my bugs. Perhaps cabal should print a warning if you have a Setup.hs file, _and_ try to use Simple? It'd at least give the hint that they're unhappy together. mark -- A UNIX signature isn't a return address, it's the ASCII equivalent of a black velvet clown painting. It's a rectangle of carets surrounding a quote from a literary giant of weeniedom like Heinlein or Dr. Who. -- Chris Maeda

On Fri, Jul 23, 2010 at 04:58, Mark Wotton
On Fri, Jul 23, 2010 at 12:33 PM, wren ng thornton
wrote: Magnus Therning wrote:
On Thu, Jul 22, 2010 at 11:52, Ross Paterson
wrote: On Thu, Jul 22, 2010 at 11:31:21AM +0100, Magnus Therning wrote:
On Thu, Jul 22, 2010 at 10:59, Ross Paterson
wrote: Magnus is building by directly running the Setup.hs himself, which ignores the Build-Type. To get cabal-install to use his Setup.hs, the Build-Type must be set to Custom.
Oh, why*2?
Why is the header there if it's not used by Cabal, and why does cabal care?
The field allows cabal to avoid compiling the Setup.hs in this case. It might also be used by other tools, e.g. one might only trust Simple packages. Not all fields are used by all tools, and several of them do not affect the operation of the library (e.g. Home-page).
All right, so why would cabal want to avoid compiling the Setup.hs?
Of course this behaviour of cabal's means that I in the future will use *Custom* all the time, since I otherwise have to remember this surprising feature of a tool I never use. Is there any reason *not* to do this?
The main reason I could think of to avoid compiling it is for performance reasons. I'm not sure how compelling that is, but...
As for why not to always use Custom, as mentioned there are cabal-aware tools out there besides cabal-install. For these other tools, there is a big difference between Simple and Custom. With Simple we (ideally) already know all the semantics of what Setup.hs does, and so we can wire that into our tools. With Custom we're forced into the position of doing Haskell source analysis since we now have to discover the semantics of an arbitrary Turing machine. That's a very high wall to climb if you're just wanting to write a simple tool for doing some kind of package analysis.
(I don't think the behavior is surprising since I interpret Simple to mean that the Setup.hs file is unused/optional. Though clearly YMMV)
Ah, this clears up one of my bugs.
Perhaps cabal should print a warning if you have a Setup.hs file, _and_ try to use Simple? It'd at least give the hint that they're unhappy together.
I don't like that idea. I don't use cabal, so I always need a Setup.hs whether the Build-Type is Simple or Custom. This suggestion would also force some tools that don't care about Build-Type (they just use the Setup.hs irrespective of Build-Type) to start caring. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

Mark Wotton wrote:
Perhaps cabal should print a warning if you have a Setup.hs file, _and_ try to use Simple? It'd at least give the hint that they're unhappy together.
I think it should instead verify that Setup.hs is consistent with a Simple build. I don't know how much variation exists, but I believe "import Distribution.Simple\nmain = defaultMain\n" is all such a Setup.hs file actually needs. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ===============================================================================

That actually runs contrary to one of cabal's other practices, which is to
add a 'simple' Setup.hs to your package as it makes the sdist is one is not
present. With your proposed change, it would then complain about _every_
package that used simple. ;)
Setup.hs exists so that you can execute runhaskell Setup.hs foo instead of
cabal foo. You just need to tell cabal if you want to delegate to Setup.hs,
by using something other than Simple as a build-type. The vast majority of
the users of cabal never bother changing the behavior of Setup.hs.
-Edward Kmett
On Thu, Jul 22, 2010 at 11:58 PM, Mark Wotton
On Fri, Jul 23, 2010 at 12:33 PM, wren ng thornton
wrote: Magnus Therning wrote:
On Thu, Jul 22, 2010 at 11:52, Ross Paterson
wrote:
On Thu, Jul 22, 2010 at 11:31:21AM +0100, Magnus Therning wrote:
On Thu, Jul 22, 2010 at 10:59, Ross Paterson
wrote: Magnus is building by directly running the Setup.hs himself, which ignores the Build-Type. To get cabal-install to use his Setup.hs, the Build-Type must be set to Custom.
Oh, why*2?
Why is the header there if it's not used by Cabal, and why does cabal care?
The field allows cabal to avoid compiling the Setup.hs in this case. It might also be used by other tools, e.g. one might only trust Simple packages. Not all fields are used by all tools, and several of them do not affect the operation of the library (e.g. Home-page).
All right, so why would cabal want to avoid compiling the Setup.hs?
Of course this behaviour of cabal's means that I in the future will use *Custom* all the time, since I otherwise have to remember this surprising feature of a tool I never use. Is there any reason *not* to do this?
The main reason I could think of to avoid compiling it is for performance reasons. I'm not sure how compelling that is, but...
As for why not to always use Custom, as mentioned there are cabal-aware tools out there besides cabal-install. For these other tools, there is a big difference between Simple and Custom. With Simple we (ideally) already know all the semantics of what Setup.hs does, and so we can wire that into our tools. With Custom we're forced into the position of doing Haskell source analysis since we now have to discover the semantics of an arbitrary Turing machine. That's a very high wall to climb if you're just wanting to write a simple tool for doing some kind of package analysis.
(I don't think the behavior is surprising since I interpret Simple to mean that the Setup.hs file is unused/optional. Though clearly YMMV)
Ah, this clears up one of my bugs.
Perhaps cabal should print a warning if you have a Setup.hs file, _and_ try to use Simple? It'd at least give the hint that they're unhappy together.
mark
-- A UNIX signature isn't a return address, it's the ASCII equivalent of a black velvet clown painting. It's a rectangle of carets surrounding a quote from a literary giant of weeniedom like Heinlein or Dr. Who. -- Chris Maeda _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Fri, Jul 23, 2010 at 03:33, wren ng thornton
Magnus Therning wrote:
On Thu, Jul 22, 2010 at 11:52, Ross Paterson
wrote: On Thu, Jul 22, 2010 at 11:31:21AM +0100, Magnus Therning wrote:
On Thu, Jul 22, 2010 at 10:59, Ross Paterson
wrote: Magnus is building by directly running the Setup.hs himself, which ignores the Build-Type. To get cabal-install to use his Setup.hs, the Build-Type must be set to Custom.
Oh, why*2?
Why is the header there if it's not used by Cabal, and why does cabal care?
The field allows cabal to avoid compiling the Setup.hs in this case. It might also be used by other tools, e.g. one might only trust Simple packages. Not all fields are used by all tools, and several of them do not affect the operation of the library (e.g. Home-page).
All right, so why would cabal want to avoid compiling the Setup.hs?
Of course this behaviour of cabal's means that I in the future will use *Custom* all the time, since I otherwise have to remember this surprising feature of a tool I never use. Is there any reason *not* to do this?
The main reason I could think of to avoid compiling it is for performance reasons. I'm not sure how compelling that is, but...
As for why not to always use Custom, as mentioned there are cabal-aware tools out there besides cabal-install. For these other tools, there is a big difference between Simple and Custom. With Simple we (ideally) already know all the semantics of what Setup.hs does, and so we can wire that into our tools. With Custom we're forced into the position of doing Haskell source analysis since we now have to discover the semantics of an arbitrary Turing machine. That's a very high wall to climb if you're just wanting to write a simple tool for doing some kind of package analysis.
(I don't think the behavior is surprising since I interpret Simple to mean that the Setup.hs file is unused/optional. Though clearly YMMV)
I always thought "Build-Type: Simple" was in some way connected to the module Distribution.Simple. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 7/22/10 09:44 , Magnus Therning wrote:
All right, so why would cabal want to avoid compiling the Setup.hs?
Of course this behaviour of cabal's means that I in the future will use *Custom* all the time, since I otherwise have to remember this surprising feature of a tool I never use. Is there any reason *not* to do this?
I would think using Simple would simplify tools that automatically create rpms/debs/etc. from hackages. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxJMgoACgkQIn7hlCsL25XVSACfWBPmzJXA0fJtjOdFp0+pFU/W QKMAn08yzo73+Cl8C24qAYxTfsSGfo2p =6mxH -----END PGP SIGNATURE-----
participants (10)
-
Brandon S Allbery KF8NH
-
Edward Kmett
-
Magnus Therning
-
Mark Wotton
-
Rogan Creswick
-
Ross Paterson
-
Sittampalam, Ganesh
-
Stephen Tetley
-
Tom Hawkins
-
wren ng thornton