Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: cabal: library and executable (Ertugrul S?ylemez)
2. Re: cabal: library and executable (harry)
3. Re: cabal: library and executable (harry)
4. Re: cabal: library and executable (emacstheviking)
5. Re: cabal: library and executable (Brent Yorgey)
----------------------------------------------------------------------
Message: 1
Date: Thu, 9 May 2013 18:10:55 +0200
From: Ertugrul S?ylemez <[email protected]>
Subject: Re: [Haskell-beginners] cabal: library and executable
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
harry <[email protected]> wrote:
> I've written a library, and a simple program to demonstrate it. I can
> write the cabal file for the library, but I can't get the executable
> section right. How can I tell it to use the library defined herein?
You need two things for this to work properly. Firstly you need to
require a sufficiently recent Cabal version, for example:
name: mylib
version: 0.1.0
cabal-version: >= 1.10
library
-- ...
Secondly to avoid double-compilation you should put your program's
source code in a different tree. My personal approach is to put the
library's source code right within the project's root directory, but the
executable's source code below a subdirectory called 'program', so the
Main module is in 'program/Main.hs'. Then just mention the package
itself as a dependency:
executable myprog
build-depends:
base >= 4.5 && < 5,
mylib
default-language: Haskell2010
ghc-options: -W -threaded -rtsopts
hs-source-dirs: program
main-is: Main.hs
If the program is just a demo that you wouldn't normally want to install
with the library, you can make it a test suite instead of an executable:
test-suite mylib-demo
type: exitcode-stdio-1.0
build-depends:
base >= 4.5 && < 5,
mylib
default-language: Haskell2010
ghc-options: -W -threaded -rtsopts
hs-source-dirs: program
main-is: Main.hs
That way the executable is only built when you configure with
--enable-tests and isn't installed together with the library. However,
keep in mind that if you have an actual test suite the demo program will
be run along with it when you command 'cabal test':
test-suite mylib-props
-- ...
To avoid that just invoke your test suite on the command line instead of
through 'cabal test':
ln -s dist/build/tests/tests
./tests
Greets,
Ertugrul
--
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130509/a7c7dd34/attachment-0001.pgp>
------------------------------
Message: 2
Date: Thu, 9 May 2013 16:13:30 +0000 (UTC)
From: harry <[email protected]>
Subject: Re: [Haskell-beginners] cabal: library and executable
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
David McBride <toad3k <at> gmail.com> writes:
>
http://hackage.haskell.org/packages/archive/manatee-editor/0.1.1/manatee-editor.cabal
Thanks for the example, but it seems to work because of the simpler
directory structure.
I've got:
src/Foo/Bar/SomeModule.hs
exec/Executable.hs
In Executable.hs, I have
import Foo.Bar.SomeModule
The library section exposes Foo.Bar.SomeModule just fine, but nothing I do
will make cabal find it when compiling Executable.hs.
On a related point, what actually happens to the executables defined in a
cabal file?
------------------------------
Message: 3
Date: Thu, 9 May 2013 16:51:58 +0000 (UTC)
From: harry <[email protected]>
Subject: Re: [Haskell-beginners] cabal: library and executable
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Ertugrul S?ylemez <es <at> ertes.de> writes:
> ...
> If the program is just a demo that you wouldn't normally want to install
> with the library, you can make it a test suite instead of an executable:
> ...
Thank you very much, that's what I'll do!
------------------------------
Message: 4
Date: Thu, 9 May 2013 21:33:05 +0100
From: emacstheviking <[email protected]>
Subject: Re: [Haskell-beginners] cabal: library and executable
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID:
<CAEiEuU+JSYCouNV8BK87m3Ci1WWd732Km+R_jvW-fB=T=vg...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Sorry Harry.
My bad. I got carried away at the prospect of trying to help out I guess...
you are right of course. The Hexwax.hs is *intended* to be a library but I
haven't got that far with it yet as it is still taking shape.
:(
On 9 May 2013 16:45, harry <[email protected]> wrote:
> emacstheviking <objitsu <at> gmail.com> writes:
>
> ...
>
> Where's the library definition? I could only find executables
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130509/a7eae66b/attachment-0001.htm>
------------------------------
Message: 5
Date: Thu, 9 May 2013 22:57:18 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] cabal: library and executable
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1
On Thu, May 09, 2013 at 06:10:55PM +0200, Ertugrul S?ylemez wrote:
>
> If the program is just a demo that you wouldn't normally want to install
> with the library, you can make it a test suite instead of an executable:
This seems like a strange hack to me. If it's not a test suite you
shouldn't call it one. Instead you can use a flag which the user has
to manually specify if they want the demo executables. Something like
flag demo
description: Install the demos.
default: False
manual: True
executable theDemo
...
if !flag(demo)
buildable: False
if flag(demo)
build-depends: base, mylib, ...
For a real-world example of this, see
http://hackage.haskell.org/package/diagrams%2Dbuilder .
-Brent
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 59, Issue 9
****************************************