Cabal Vs runhaskell when to use?

In haskell build system Cabal

, and runhaskell

has almost the same set of subcommands configure

, build

. For runhaskell, these are:

runhaskell Setup.hs configure
runhaskell Setup.hs build

      

... whereas for cabal it is:

cabal build
cabal configure

      

So when should I use this command? Do both teams have the same functionality?

Is it possible to run runhaskell

without sudo access, because I can see what is runhaskell

doing the entries internally /opt/ghc/7.8.4/lib

, whereas cabal is running in sudo / non-sudo mode?

+3


source to share


3 answers


cabal

and runhaskell

serve a completely different purpose.       runhaskell

used to execute Haskell programs without having to compile them. You can place this at the top of your Haskell: file #!/usr/bin/env runhaskell

and enable scripting. cabal

is a package manager and build system for Haskell.

Also, cabal

and runhaskell

not share their subcommands, such as     configure

, build

, install

, etc.


i saw in this link bob.ippoli.to/archives/2013/01/11/getting-started-with-haskell, two commands are used ... runhaskell Setup.hs configure && & & runhaskell Setup.hs build

Usually Setup.hs

has the following code when generated from cabal init

:



import Distribution.Simple
main = defaultMain

      

Now, if you see the defaultMain implementation :

defaultMain :: IO ()
defaultMain = getArgs >>= defaultMainHelper simpleUserHooks

      

So, what you are passing in are actually command line arguments, which can be anything. You can actually check it yourself:

$ runhaskell Setup.hs invalid_argument
unrecognised command: invalid_argument (try --help)

      

+5


source


runhaskell

has no subcommands:

$ runhaskell --help
Usage: runghc flags [runghc] [GHC module] [program arguments]



It takes the path to the Haskell source file and executes it right away. Therefore, you should use it when all you need to do is run some Haskell code that you have. You can of course use it runhaskell

without superuser access; I doubt he is creating anything in the /opt

.

Cabal is a build system for Haskell projects that aims to convert Haskell sources to binaries.

+2


source


The problem is the Cabal user manual has batch-wide instructions for configuring, building and installing with runhaskell! And it is not clear when to use cabal commands and when to use runhaskell or they are interchangeable. This whole system is a weak link in Haskell (eg not uninstalling a package in any way, exacerbated by warnings that reinstallations are "always dangerous" without any explanation, since you develop, install as you develop, if reinstalling is dangerous "? ), a real obstacle to using the language, or at least ghc.

0


source







All Articles