stack, git, directory structure

I have a few basic questions about my project organization using stack. I'm going to have several executables and a hierarchical library. For instance, let's say I'm going to call my overall system "cac" (computer aided composition). I'll have imports like import Cac.Util import Cac.Search import Cac.Search.Algo1 -- some modules that assist things import XDoc import XDoc.Parse and so on. I'll have executables named 'foo', 'bar', etc. So would the following be correct? - call the directory where I put all stack packages $PROJ - call the top level of my specific project $PROJ/cac, which will have $PROJ/cac/cac.cabal - I'll have the following files and dirs: - modules: - $PROJ/cac/src/Cac.hs - $PROJ/cac/src/Cac/ - $PROJ/cac/src/Cac/Util.hs - $PROJ/cac/src/Cac/Search.hs - $PROJ/cac/src/Cac/Search/ - $PROJ/cac/src/XDoc.hs - $PROJ/cac/src/XDoc/ - $PROJ/cac/src/XDoc/Parse.hs - executables: - $PROJ/app/foo.hs - $PROJ/app/bar.hs Also, if I'm going to use git, would my .git/ directory be at $PROJ/cac/.git/ ? thanks D

Dennis Raddle
I have a few basic questions about my project organization using stack.
I'm going to have several executables and a hierarchical library.
For instance, let's say I'm going to call my overall system "cac" (computer aided composition). I'll have imports like
import Cac.Util import Cac.Search import Cac.Search.Algo1 -- some modules that assist things import XDoc import XDoc.Parse
and so on.
I'll have executables named 'foo', 'bar', etc.
So would the following be correct?
- call the directory where I put all stack packages $PROJ
- call the top level of my specific project $PROJ/cac, which will have $PROJ/cac/cac.cabal
- I'll have the following files and dirs:
- modules:
- $PROJ/cac/src/Cac.hs - $PROJ/cac/src/Cac/ - $PROJ/cac/src/Cac/Util.hs - $PROJ/cac/src/Cac/Search.hs - $PROJ/cac/src/Cac/Search/ - $PROJ/cac/src/XDoc.hs - $PROJ/cac/src/XDoc/ - $PROJ/cac/src/XDoc/Parse.hs
- executables:
- $PROJ/app/foo.hs - $PROJ/app/bar.hs
Also, if I'm going to use git, would my .git/ directory be at $PROJ/cac/.git/ ?
Depending a little on how tightly coupled lib and exes are I'd either put all into a single Cabal file: cac/ .git/... cac.cabal stack.yaml src/ Cac.hs Cac/ Util.hs ... app/ foo.hs bar.hs Or lib and exes in separate folders: $PROJ/ .git/... stack.yaml cac/ cac.cabal src/ Cac.hs Cac/ Util.hs ... app/ app.cabal foo.hs bar.hs Or maybe even each exe into its own folder. /M -- Magnus Therning OpenPGP: 0x927912051716CE39 email: magnus@therning.org jabber: magnus@therning.org twitter: magthe http://therning.org/magnus Computer Science: "In low-level languages like C" Computer Engineering: "In high-level languages like C"

I got a private reply which helps but it made me think of another question. In the stack demo, there's one executable 'helloworld-exe' which is compiled from app/Main.hs. If I'm going to have several executables, what do I call the source files, and how do I control the file name of the executable that gets built? Thanks, D

You can name the source files whatever you like, and you can associate them
with your desired ececutable names in the cabal file.
Eg. In a cabal file:
...
executable zshhs
main-is: ZshClone.hs
hs-source-dirs: src
...
Where "zshhs" is the desired binary output name, and the directory
containing this cabal file also contains "src/ZshClone.hs" with your main
function.
On Sun, May 28, 2017 at 14:46 Dennis Raddle
I got a private reply which helps but it made me think of another question.
In the stack demo, there's one executable 'helloworld-exe' which is compiled from app/Main.hs.
If I'm going to have several executables, what do I call the source files, and how do I control the file name of the executable that gets built?
Thanks, D
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Dennis Raddle
I got a private reply which helps but it made me think of another question.
In the stack demo, there's one executable 'helloworld-exe' which is compiled from app/Main.hs.
If I'm going to have several executables, what do I call the source files, and how do I control the file name of the executable that gets built?
AFAIU that's what the `executable: <name>` in your .cabal does. This is the text describing executable sections at [1]. Executable sections (if present) describe executable programs contained in the package and must have an argument after the section label, which defines the name of the executable. This is a freeform argument but may not contain spaces. And you control the source files using `main-is:` and `other-modules:`. One common pattern I've seen is to put most source files into a library and then have each executable use that library and have a very "thin" main source file. /M [1]: https://www.haskell.org/cabal/users-guide/developing-packages.html#executabl... -- Magnus Therning OpenPGP: 0x927912051716CE39 email: magnus@therning.org jabber: magnus@therning.org twitter: magthe http://therning.org/magnus The greatest performance improvement of all is when a system goes from not-working to working. — John Ousterhout
participants (3)
-
Dennis Raddle
-
Magnus Therning
-
Patrick Redmond