[Haskell-cafe] stack, git, directory structure

Magnus Therning magnus at therning.org
Sun May 28 21:22:33 UTC 2017


Dennis Raddle <dennis.raddle at gmail.com> writes:

> 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 at therning.org   jabber: magnus at therning.org
twitter: magthe               http://therning.org/magnus

Computer Science: "In low-level languages like C"
Computer Engineering: "In high-level languages like C"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170528/9e778472/attachment.sig>


More information about the Haskell-Cafe mailing list