A Cabal problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

A Cabal problem

Mario Blažević
        I have a problem with Cabal: it doesn't seem to pick up the "Main-is:"
option from the configuration file.

Here's my "scc.cabal" file. Note the "Main-is:" line:

> Name:                scc
> Version:             0.1
> Cabal-Version:       >= 1.2
> Build-Type:          Simple
> License:             GPL
> License-file:        LICENSE.txt
> Copyright:           (c) 2008 Mario Blazevic
> Author:              Mario Blazevic
> Maintainer:          [hidden email]
> Synopsis:            Streaming component combinators
>
> Executable shsh
>   Main-is:           Shell.hs
>   Other-Modules:     Foundation, ComponentTypes, Components, Combinators
>   Build-Depends:     base, containers, process, readline, parsec
>
> Library
>   Exposed-Modules:   Foundation, ComponentTypes, Components, Combinators
>   Build-Depends:     base, containers

        And below are the outputs of Cabal configure and build commands. Note
the absence of "--main-is" ghc command-line option. I'm doing this on
Ubuntu 8.04 Linux, but I get the same problem with Gentoo. Is there
something wrong with my configuration file, or is this a bug in Cabal?


> ~/scc/pipe$ runhaskell Setup.lhs configure --verbose --prefix=~
> Configuring scc-0.1...
> Dependency base-any: using base-3.0.1.0
> Dependency containers-any: using containers-0.1.0.1
> Dependency process-any: using process-1.0.0.0
> Dependency readline-any: using readline-1.0.1.0
> Dependency parsec-any: using parsec-2.1.0.0
> Using compiler: ghc-6.8.2
> Using install prefix: ~
> Binaries installed in: ~/bin
> Libraries installed in: ~/lib/scc-0.1/ghc-6.8.2
> Private binaries installed in: ~/libexec
> Data files installed in: ~/share/scc-0.1
> Documentation installed in: ~/share/doc/scc-0.1
> No alex found
> Using ar found on system at: /usr/bin/ar
> No c2hs found
> No cpphs found
> No ffihugs found
> Using ghc version 6.8.2 found on system at: /usr/bin/ghc
> Using ghc-pkg version 6.8.2 found on system at: /usr/bin/ghc-pkg
> No greencard found
> Using haddock version 0.8 found on system at: /usr/bin/haddock
> No happy found
> No hmake found
> Using hsc2hs version 0.66-ghc found on system at: /usr/bin/hsc2hs
> No hscolour found
> No hugs found
> No jhc found
> Using ld found on system at: /usr/bin/ld
> No nhc98 found
> No pfesetup found
> Using pkg-config version 0.22 found on system at: /usr/bin/pkg-config
> Using ranlib found on system at: /usr/bin/ranlib
> Using tar found on system at: /bin/tar
>
> ~/scc/pipe$ runhaskell Setup.lhs build --verbose
> Creating dist/build (and its parents)
> Creating dist/build/autogen (and its parents)
> Preprocessing library scc-0.1...
> Preprocessing executables for scc-0.1...
> Building scc-0.1...
> Building library...
> Creating dist/build (and its parents)
> Creating dist/build (and its parents)
> /usr/bin/ghc -package-name scc-0.1 --make -hide-all-packages -i
> -idist/build/autogen -idist/build -i. -Idist/build -odir dist/build
> -hidir dist/build -stubdir dist/build -package base-3.0.1.0 -package
> containers-0.1.0.1 -package process-1.0.0.0 -package readline-1.0.1.0
> -package parsec-2.1.0.0 -O Foundation ComponentTypes Components Combinators
> [1 of 4] Compiling Foundation       ( Foundation.hs,
> dist/build/Foundation.o )
> [2 of 4] Compiling ComponentTypes   ( ComponentTypes.hs,
> dist/build/ComponentTypes.o )
> [3 of 4] Compiling Components       ( Components.hs,
> dist/build/Components.o )
> [4 of 4] Compiling Combinators      ( Combinators.hs,
> dist/build/Combinators.o )
> Linking...
> /usr/bin/ar q dist/build/libHSscc-0.1.a dist/build/Foundation.o
> dist/build/ComponentTypes.o dist/build/Components.o dist/build/Combinators.o
> /usr/bin/ar: creating dist/build/libHSscc-0.1.a
> /usr/bin/ld -x -r -o dist/build/HSscc-0.1.o.tmp dist/build/Foundation.o
> dist/build/ComponentTypes.o dist/build/Components.o dist/build/Combinators.o
> Building executable: shsh...
> Creating dist/build/shsh (and its parents)
> Creating dist/build/shsh/shsh-tmp (and its parents)
> Creating dist/build/shsh/shsh-tmp (and its parents)
> /usr/bin/ghc -o dist/build/shsh/shsh --make -hide-all-packages -i
> -idist/build/autogen -idist/build/shsh/shsh-tmp -i.
> -Idist/build/shsh/shsh-tmp -odir dist/build/shsh/shsh-tmp -hidir
> dist/build/shsh/shsh-tmp -stubdir dist/build/shsh/shsh-tmp -package
> base-3.0.1.0 -package containers-0.1.0.1 -package process-1.0.0.0
> -package readline-1.0.1.0 -package parsec-2.1.0.0 -O ./Shell.hs
> [1 of 5] Compiling Foundation       ( Foundation.hs,
> dist/build/shsh/shsh-tmp/Foundation.o )
> [2 of 5] Compiling ComponentTypes   ( ComponentTypes.hs,
> dist/build/shsh/shsh-tmp/ComponentTypes.o )
> [3 of 5] Compiling Components       ( Components.hs,
> dist/build/shsh/shsh-tmp/Components.o )
> [4 of 5] Compiling Combinators      ( Combinators.hs,
> dist/build/shsh/shsh-tmp/Combinators.o )
> [5 of 5] Compiling Shell            ( ./Shell.hs,
> dist/build/shsh/shsh-tmp/Shell.o )
> Warning: output was redirected with -o, but no output will be generated
> because there is no Main module.




Name:                scc
Version:             0.1
Cabal-Version:       >= 1.2
Build-Type:          Simple
License:             GPL
License-file:        LICENSE.txt
Copyright:           (c) 2008 Mario Blazevic
Author:              Mario Blazevic
Maintainer:          [hidden email]
Synopsis:            Streaming component combinators

Executable shsh
  Main-is:           Shell.hs
  Other-Modules:     Foundation, ComponentTypes, Components, Combinators
  Build-Depends:     base, containers, process, readline, parsec

Library
  Exposed-Modules:   Foundation, ComponentTypes, Components, Combinators
  Build-Depends:     base, containers



#! /usr/bin/env runhaskell
 
> import Distribution.Simple
> main = defaultMain



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A Cabal problem

Trevor Elliott-3
Hi Mario,

Is the name of the module within the Shell.hs file Main?  If not, that
could be your problem.

--trevor

On Mon, 05 May 2008 09:57:15 -0400
Mario Blazevic <[hidden email]> wrote:

> I have a problem with Cabal: it doesn't seem to pick up the
> "Main-is:" option from the configuration file.
>
> Here's my "scc.cabal" file. Note the "Main-is:" line:
>
> > Name:                scc
> > Version:             0.1
> > Cabal-Version:       >= 1.2
> > Build-Type:          Simple
> > License:             GPL
> > License-file:        LICENSE.txt
> > Copyright:           (c) 2008 Mario Blazevic
> > Author:              Mario Blazevic
> > Maintainer:          [hidden email]
> > Synopsis:            Streaming component combinators
> >
> > Executable shsh
> >   Main-is:           Shell.hs
> >   Other-Modules:     Foundation, ComponentTypes, Components,
> > Combinators Build-Depends:     base, containers, process, readline,
> > parsec
> >
> > Library
> >   Exposed-Modules:   Foundation, ComponentTypes, Components,
> > Combinators Build-Depends:     base, containers
>
>
> And below are the outputs of Cabal configure and build
> commands. Note the absence of "--main-is" ghc command-line option.
> I'm doing this on Ubuntu 8.04 Linux, but I get the same problem with
> Gentoo. Is there something wrong with my configuration file, or is
> this a bug in Cabal?
>
>
> > ~/scc/pipe$ runhaskell Setup.lhs configure --verbose --prefix=~
> > Configuring scc-0.1...
> > Dependency base-any: using base-3.0.1.0
> > Dependency containers-any: using containers-0.1.0.1
> > Dependency process-any: using process-1.0.0.0
> > Dependency readline-any: using readline-1.0.1.0
> > Dependency parsec-any: using parsec-2.1.0.0
> > Using compiler: ghc-6.8.2
> > Using install prefix: ~
> > Binaries installed in: ~/bin
> > Libraries installed in: ~/lib/scc-0.1/ghc-6.8.2
> > Private binaries installed in: ~/libexec
> > Data files installed in: ~/share/scc-0.1
> > Documentation installed in: ~/share/doc/scc-0.1
> > No alex found
> > Using ar found on system at: /usr/bin/ar
> > No c2hs found
> > No cpphs found
> > No ffihugs found
> > Using ghc version 6.8.2 found on system at: /usr/bin/ghc
> > Using ghc-pkg version 6.8.2 found on system at: /usr/bin/ghc-pkg
> > No greencard found
> > Using haddock version 0.8 found on system at: /usr/bin/haddock
> > No happy found
> > No hmake found
> > Using hsc2hs version 0.66-ghc found on system at: /usr/bin/hsc2hs
> > No hscolour found
> > No hugs found
> > No jhc found
> > Using ld found on system at: /usr/bin/ld
> > No nhc98 found
> > No pfesetup found
> > Using pkg-config version 0.22 found on system
> > at: /usr/bin/pkg-config Using ranlib found on system
> > at: /usr/bin/ranlib Using tar found on system at: /bin/tar
> >
> > ~/scc/pipe$ runhaskell Setup.lhs build --verbose
> > Creating dist/build (and its parents)
> > Creating dist/build/autogen (and its parents)
> > Preprocessing library scc-0.1...
> > Preprocessing executables for scc-0.1...
> > Building scc-0.1...
> > Building library...
> > Creating dist/build (and its parents)
> > Creating dist/build (and its parents)
> > /usr/bin/ghc -package-name scc-0.1 --make -hide-all-packages -i
> > -idist/build/autogen -idist/build -i. -Idist/build -odir dist/build
> > -hidir dist/build -stubdir dist/build -package base-3.0.1.0
> > -package containers-0.1.0.1 -package process-1.0.0.0 -package
> > readline-1.0.1.0 -package parsec-2.1.0.0 -O Foundation
> > ComponentTypes Components Combinators [1 of 4] Compiling
> > Foundation       ( Foundation.hs, dist/build/Foundation.o )
> > [2 of 4] Compiling ComponentTypes   ( ComponentTypes.hs,
> > dist/build/ComponentTypes.o )
> > [3 of 4] Compiling Components       ( Components.hs,
> > dist/build/Components.o )
> > [4 of 4] Compiling Combinators      ( Combinators.hs,
> > dist/build/Combinators.o )
> > Linking...
> > /usr/bin/ar q dist/build/libHSscc-0.1.a dist/build/Foundation.o
> > dist/build/ComponentTypes.o dist/build/Components.o
> > dist/build/Combinators.o /usr/bin/ar: creating
> > dist/build/libHSscc-0.1.a /usr/bin/ld -x -r -o
> > dist/build/HSscc-0.1.o.tmp dist/build/Foundation.o
> > dist/build/ComponentTypes.o dist/build/Components.o
> > dist/build/Combinators.o Building executable: shsh... Creating
> > dist/build/shsh (and its parents) Creating dist/build/shsh/shsh-tmp
> > (and its parents) Creating dist/build/shsh/shsh-tmp (and its
> > parents) /usr/bin/ghc -o dist/build/shsh/shsh --make
> > -hide-all-packages -i -idist/build/autogen
> > -idist/build/shsh/shsh-tmp -i. -Idist/build/shsh/shsh-tmp -odir
> > dist/build/shsh/shsh-tmp -hidir dist/build/shsh/shsh-tmp -stubdir
> > dist/build/shsh/shsh-tmp -package base-3.0.1.0 -package
> > containers-0.1.0.1 -package process-1.0.0.0 -package
> > readline-1.0.1.0 -package parsec-2.1.0.0 -O ./Shell.hs [1 of 5]
> > Compiling Foundation       ( Foundation.hs,
> > dist/build/shsh/shsh-tmp/Foundation.o ) [2 of 5] Compiling
> > ComponentTypes   ( ComponentTypes.hs,
> > dist/build/shsh/shsh-tmp/ComponentTypes.o ) [3 of 5] Compiling
> > Components       ( Components.hs,
> > dist/build/shsh/shsh-tmp/Components.o ) [4 of 5] Compiling
> > Combinators      ( Combinators.hs,
> > dist/build/shsh/shsh-tmp/Combinators.o ) [5 of 5] Compiling
> > Shell            ( ./Shell.hs, dist/build/shsh/shsh-tmp/Shell.o )
> > Warning: output was redirected with -o, but no output will be
> > generated because there is no Main module.
>
>
>
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A Cabal problem

Mario Blažević
Trevor Elliott wrote:
> Hi Mario,
>
> Is the name of the module within the Shell.hs file Main?  If not, that
> could be your problem.

        You may be right, the module's name is Shell, not Main. GHC does not
have problem with that when "--main-is Shell" option is specified on the
command line. Is Cabal different? Is this documented somewhere?


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A Cabal problem

Trevor Elliott-3
On Mon, 05 May 2008 13:37:12 -0400
Mario Blazevic <[hidden email]> wrote:

> Trevor Elliott wrote:
> > Hi Mario,
> >
> > Is the name of the module within the Shell.hs file Main?  If not,
> > that could be your problem.
>
> You may be right, the module's name is Shell, not Main. GHC
> does not have problem with that when "--main-is Shell" option is
> specified on the command line. Is Cabal different? Is this documented
> somewhere?

Cabal doesn't pass the --main-is option, I believe because it is
specific to GHC.  What you could do is add this flag in the ghc-options
field of your executable in the cabal file, like this:

ghc-options: --main-is Shell

--trevor
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A Cabal problem

Duncan Coutts
In reply to this post by Mario Blažević

On Mon, 2008-05-05 at 13:37 -0400, Mario Blazevic wrote:
> Trevor Elliott wrote:
> > Hi Mario,
> >
> > Is the name of the module within the Shell.hs file Main?  If not, that
> > could be your problem.
>
> You may be right, the module's name is Shell, not Main. GHC does not
> have problem with that when "--main-is Shell" option is specified on the
> command line. Is Cabal different? Is this documented somewhere?

The ghc flag and the cabal field happen to have the same name but they
do not mean quite the same thing.

The ghc flag means "this *module* is the Main module, despite whatever
the real name of the module might be" while the cabal flag means "this
*file* is the Main module". The cabal concept is portable between all
supported Haskell implementations and the ghc flag is ghc-specific.

For the moment we have decided not to provide any support for this
ghc-specific feature:

http://hackage.haskell.org/trac/hackage/ticket/179

Do please add your comments/opinions to that ticket.

Duncan

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A Cabal problem

Mario Blažević
In reply to this post by Trevor Elliott-3
Trevor Elliott wrote:

> On Mon, 05 May 2008 13:37:12 -0400
> Mario Blazevic <[hidden email]> wrote:
>
>> Trevor Elliott wrote:
>>> Hi Mario,
>>>
>>> Is the name of the module within the Shell.hs file Main?  If not,
>>> that could be your problem.
>> You may be right, the module's name is Shell, not Main. GHC
>> does not have problem with that when "--main-is Shell" option is
>> specified on the command line. Is Cabal different? Is this documented
>> somewhere?
>
> Cabal doesn't pass the --main-is option, I believe because it is
> specific to GHC.  What you could do is add this flag in the ghc-options
> field of your executable in the cabal file, like this:
>
> ghc-options: --main-is Shell

        That worked like charm, except the two dashes should be one (my
mistake). Thank you.


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A Cabal problem

Duncan Coutts

On Tue, 2008-05-06 at 09:43 -0400, Mario Blazevic wrote:
> Trevor Elliott wrote:

> > Cabal doesn't pass the --main-is option, I believe because it is
> > specific to GHC.  What you could do is add this flag in the ghc-options
> > field of your executable in the cabal file, like this:
> >
> > ghc-options: --main-is Shell
>
> That worked like charm, except the two dashes should be one (my
> mistake). Thank you.

Note that hackage will reject packages that use "ghc-options: -main-is"
with the message that it is not portable. The rationale is that unlike
other non-portable extensions, it is easy to change to make it portable:
http://hackage.haskell.org/trac/hackage/ticket/179
If you want to argue for supporting this ghc extension and/or implement
support (possibly with workaround support for the other haskell
implementations) then please do comment on the above ticket.

Duncan

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: A Cabal problem

Mario Blažević
Duncan Coutts wrote:

> On Tue, 2008-05-06 at 09:43 -0400, Mario Blazevic wrote:
>> Trevor Elliott wrote:
>
>>> Cabal doesn't pass the --main-is option, I believe because it is
>>> specific to GHC.  What you could do is add this flag in the ghc-options
>>> field of your executable in the cabal file, like this:
>>>
>>> ghc-options: --main-is Shell
>> That worked like charm, except the two dashes should be one (my
>> mistake). Thank you.
>
> Note that hackage will reject packages that use "ghc-options: -main-is"
> with the message that it is not portable. The rationale is that unlike
> other non-portable extensions, it is easy to change to make it portable:
> http://hackage.haskell.org/trac/hackage/ticket/179
> If you want to argue for supporting this ghc extension and/or implement
> support (possibly with workaround support for the other haskell
> implementations) then please do comment on the above ticket.
>
> Duncan
>

        After some experimentation, I've changed my opinion and now agree with
the current behaviour. I had the impression that every Haskell module
had to reside in a same-named file. While this appears to be true for
*imported* modules and GHC (hence my mistaken impression), the Haskell
98 standard does not specify anything of the sort. In case of the
top-level module, GHC (as well as the standard) allows it to reside in a
file of any name. So the only reasonable use for -main-is option, as I
see it, is to allow multiple small main modules residing in the same
file, and I guess that's not likely to be encountered in a package.


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe